Reputation: 19193
I am trying to set up i18next on my node.js app. I have for now two languages : fr-CA and en-US.
I would like to have fr-CA as default language. I set it up like this in my app.js, before the configuration, :
i18next.init({
debug: true,
lng: 'fr-CA',
ignoreRoutes: [
'img/',
'public/',
'stylesheets/',
'js/'
]
});
Here is my folder structure
locales/
dev/
translation.json
en/
translation.json
fr-CA/
translation.json
fr/
translation.json
I do a console log on server launch to see what's the i18next.lng() value, and it says fr-CA
. However, as soon as I load a page, the console says currentLng set to: en-US
. So it always tries to load the locales/en/translation.json file.
The debug shows that when launching the server it loads the fr-CA, fr and dev files. But as soon as a page launches it loads the en file and it's like it completely forgot about fr-CA. My browser is in English so I guess it takes this value from there. But I can't seem to find why it changes.
Did I miss something here?
Thanks
Upvotes: 1
Views: 706
Reputation: 4498
defining a fallbackLanguage is done by setting fallbackLng
not lng
!
i18next.init({
debug: true,
fallbackLng: 'fr-CA',
ignoreRoutes: [
'img/',
'public/',
'stylesheets/',
'js/'
]
});
Upvotes: 1