add language attribute to <html>

This commit is contained in:
or-else
2021-09-16 11:31:27 -07:00
parent 7bcfd974cb
commit 7117955126
+5 -4
View File
@@ -23,10 +23,11 @@ const language = (params && params.hl) ||
const baseLanguage = language.toLowerCase().split(/[-_]/)[0];
// Try the full locale first, then the locale without the region code, fallback to 'en'.
const messages =
allMessages[language] ||
allMessages[baseLanguage] ||
allMessages.en;
const htmlLang = allMessages[language] ? langauge : allMessages[baseLanguage] ? baseLanguage : 'en';
const messages = allMessages[htmlLang];
// Set lang attribute of the HTML element: <html lang="XX">
document.getElementsByTagName('html')[0].setAttribute('lang', htmlLang);
ReactDOM.render(
<React.StrictMode>