♿️(frontend) update html lang on language change
Performs lang attribute update on html tag on every language change. By default the attribute value uses the i18n.language value.
This commit is contained in:
committed by
Sebastien Nobour
parent
bea23cc6e9
commit
dfb5394310
@@ -16,6 +16,11 @@ i18n
|
||||
preload: LANGUAGES_ALLOWED,
|
||||
nsSeparator: '||',
|
||||
})
|
||||
.then(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
document.documentElement.lang = i18n.language;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error('i18n initialization failed');
|
||||
});
|
||||
@@ -24,6 +29,7 @@ i18n
|
||||
i18n.on('languageChanged', (lng) => {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem(LANGUAGE_LOCAL_STORAGE, lng);
|
||||
document.documentElement.lang = lng;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import '@/i18n/initI18n';
|
||||
|
||||
export default function RootLayout() {
|
||||
return (
|
||||
<Html lang="en">
|
||||
<Html>
|
||||
<Head />
|
||||
<body suppressHydrationWarning={process.env.NODE_ENV === 'development'}>
|
||||
<Main />
|
||||
|
||||
Reference in New Issue
Block a user