diff options
Diffstat (limited to 'shared/localization/src/setHTMLAttributes.ts')
| -rw-r--r-- | shared/localization/src/setHTMLAttributes.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/shared/localization/src/setHTMLAttributes.ts b/shared/localization/src/setHTMLAttributes.ts new file mode 100644 index 0000000..3bc0725 --- /dev/null +++ b/shared/localization/src/setHTMLAttributes.ts @@ -0,0 +1,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); + } +} |
