Closed dyniper closed 5 years ago
read the documentation: https://www.i18next.com/principles/fallback#language-fallback
resolve order is: en-US -> en -> fallbackLng
so fr-CA
will also try to load fr
(by default it assumes you only translated the things spelled different from fr in fr-CA not all the strings).
you can play with: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources the load
option
Sorry if I didn't explain correctly. It is fine that it's trying to load fr.json
according to the fallback logic. What I find odd, is that the callback to changeLanguage receive errors of it. Because of it, there is no way to distinguish a real failure (no language files found at all of the a given locale), and failing getting a fallback language.
i guess loading fallbackLng will work always - so every not loaded is an error - work with whitelist option to avoid loading non supported languages.
When using i18next in combination with i18next-xhr-backend, the language lookup sequence leads to errors in the changeLanguage callback.
Given this init:
and changeLanguage:
If my string resource is simply
fr-CA.json
, the callback in changeLanguage will receive an error (failed loading .../tests/fr.json
).This makes it impossible to know if the resource could not be found at all, or if it was found using some fallback lookup. In the example i gave, i don't even understand why it's even trying to load
fr.json
, as the requested language isfr-CA
.But the same problem happens if i have
en.json
resource and request language foren-UK
. It will work (by loading en.json), but still have an error in the changeLanguage callback. Wouldn't it only make sense to have errors if the resource could not be loaded at all?Thanks!