Reputation: 26307
I'm using i18next-node for localization of my app.
I have two languages: en-CA
and fr-CA
I'm using this to init the app:
i18next.init({
saveMissing: true,
sendMissingTo : 'all',
ignoreRoutes: ['img/','images/', 'public/', 'css/', 'js/'],
debug: true,
lng: 'en-CA'
});
The problem is, when I start the app, it gives me this error:
currentLng set to: en-US
[ { [Error: ENOENT, open 'locales/en-US/translation.json']
errno: 34,
code: 'ENOENT',
path: 'locales/en-US/translation.json' } ]
I don't want en-US, I want en-CA. Now, my app isn't showing either language. How do I set en-CA to be the default?
Upvotes: 1
Views: 4501
Reputation: 4498
Try to read the detect language section under http://i18next.com/node/pages/doc_init.html
i18next detects during the request the language from your browser-settings (if not set by any other methode - cookie, querystring). That's why language is set to 'en-US'.
You can set the supported languages on init: i18n.init({supportedLngs: ['en-CA', 'fr-CA']})
But you still need to set a fallbackLng -> eg. if someone requests your page with language set 'de' some fallback language should be displayed.
Upvotes: 0
Reputation: 26307
Turns out you can set fallbackLng : 'en-CA'
and that will work. Kind of a hack though.
Upvotes: 1