summaryrefslogtreecommitdiff
path: root/shared/localization/src/setHTMLAttributes.ts
blob: 3bc0725267f63dcdbedc160a9478f9b9f744d13c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { getLocAttributes } from './getLocAttributes';

/**
 * sets Language attributes to HTML tag.
 * @param {string} language
 * @returns {void}
 */
export function setHTMLAttributes(language: string): void {
    if (typeof window === 'undefined') return;
    const attributes = getLocAttributes(language);

    for (let [attribute, value] of Object.entries(attributes)) {
        window.document.documentElement.setAttribute(attribute, value);
    }
}