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]; const baseLanguage = language.toLowerCase().split(/[-_]/)[0];
// Try the full locale first, then the locale without the region code, fallback to 'en'. // Try the full locale first, then the locale without the region code, fallback to 'en'.
const messages = const htmlLang = allMessages[language] ? langauge : allMessages[baseLanguage] ? baseLanguage : 'en';
allMessages[language] || const messages = allMessages[htmlLang];
allMessages[baseLanguage] ||
allMessages.en; // Set lang attribute of the HTML element: <html lang="XX">
document.getElementsByTagName('html')[0].setAttribute('lang', htmlLang);
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>