From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- shared/localization/src/setHTMLAttributes.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 shared/localization/src/setHTMLAttributes.ts (limited to 'shared/localization/src/setHTMLAttributes.ts') 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); + } +} -- cgit v1.2.3