add language attribute to <html>
This commit is contained in:
+5
-4
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user