Skip to content

Commit

Permalink
Merge pull request #4059 from ProjectMirador/initialize-i18n
Browse files Browse the repository at this point in the history
Initialize the i18n instance with the correct locale.
  • Loading branch information
marlo-longley authored Dec 18, 2024
2 parents d5b1bc9 + e5d1414 commit d19b3bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
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

0 comments on commit d19b3bd

Please sign in to comment.