diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /shared/localization/src/setHTMLAttributes.ts | |
init commit
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); + } +} |
