/ shared / localization / src / setHTMLAttributes.ts
setHTMLAttributes.ts
 1  import { getLocAttributes } from './getLocAttributes';
 2  
 3  /**
 4   * sets Language attributes to HTML tag.
 5   * @param {string} language
 6   * @returns {void}
 7   */
 8  export function setHTMLAttributes(language: string): void {
 9      if (typeof window === 'undefined') return;
10      const attributes = getLocAttributes(language);
11  
12      for (let [attribute, value] of Object.entries(attributes)) {
13          window.document.documentElement.setAttribute(attribute, value);
14      }
15  }