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