Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize the i18n instance with the correct locale. #4059

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/AppProviders.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ FullScreenShim.propTypes = {
* plugins + config to inject additional translations.
*/
const StoreAwareI18nextProvider = ({ children, language, translations }) => {
const [i18n] = useState(createI18nInstance());
const [i18n] = useState(createI18nInstance({ lng: language }));
useEffect(() => {
i18n.changeLanguage(language);
if (i18n && i18n.language !== language) i18n.changeLanguage(language);
}, [i18n, language]);

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import nbNo from './locales/nbNo/translation.json';
/**
* Load translations for each language
*/
function createI18nInstance() {
function createI18nInstance(i18nConfig = {}) {
const resources = {
ar,
bg,
Expand Down Expand Up @@ -58,6 +58,7 @@ function createI18nInstance() {
},
lng: 'en',
resources,
...i18nConfig,
});

return instance;
Expand Down
Loading