mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 09:25:46 +00:00
Update lang
attribute on locale change
This commit is contained in:
parent
2c43eb4e39
commit
55efd7b034
@ -22,6 +22,7 @@ import {
|
|||||||
} from './exposedHooks';
|
} from './exposedHooks';
|
||||||
import injectionZones from './injectionZones';
|
import injectionZones from './injectionZones';
|
||||||
import favicon from './favicon.ico';
|
import favicon from './favicon.ico';
|
||||||
|
import localStorageKey from './components/LanguageProvider/utils/localStorageKey';
|
||||||
|
|
||||||
class StrapiApp {
|
class StrapiApp {
|
||||||
constructor({ adminConfig, appPlugins, library, middlewares, reducers }) {
|
constructor({ adminConfig, appPlugins, library, middlewares, reducers }) {
|
||||||
@ -425,6 +426,8 @@ class StrapiApp {
|
|||||||
fields: { fields },
|
fields: { fields },
|
||||||
} = this.library;
|
} = this.library;
|
||||||
|
|
||||||
|
console.log({ settings: this.settings });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Providers
|
<Providers
|
||||||
authLogo={this.configurations.authLogo}
|
authLogo={this.configurations.authLogo}
|
||||||
@ -457,6 +460,7 @@ class StrapiApp {
|
|||||||
href: this.configurations.head.favicon,
|
href: this.configurations.head.favicon,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
htmlAttributes={{ lang: localStorage.getItem(localStorageKey) || 'en' }}
|
||||||
/>
|
/>
|
||||||
<BrowserRouter basename={basename}>
|
<BrowserRouter basename={basename}>
|
||||||
<App store={store} />
|
<App store={store} />
|
||||||
|
@ -21,6 +21,7 @@ const LanguageProvider = ({ children, localeNames, messages }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Set user language in local storage.
|
// Set user language in local storage.
|
||||||
window.localStorage.setItem(localStorageKey, locale);
|
window.localStorage.setItem(localStorageKey, locale);
|
||||||
|
document.documentElement.setAttribute('lang', locale);
|
||||||
}, [locale]);
|
}, [locale]);
|
||||||
|
|
||||||
const changeLocale = (locale) => {
|
const changeLocale = (locale) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user