I often get the following error:
i18next::translator: missingKey fr common my key.
whereas the key is in the translation file (which is correctly loaded and taken into account). Why?
Edit:
This happens when I have a .
(dot character) in a key in the translation file.
The translation file must be a valid JSON file and cannot contain keys with the .
(dot) character. i18next will complain of a missing key if the key contains a dot.
If i could guess i'm rather sure you're accessing the t
function to early -> before the translations where loaded from the backend.
i18next.init({
lng: 'en',
debug: true
}, function(err, t) {
// initialized and ready to go!
i18next.t('key'); // -> ok
});
i18next.t('key'); // -> not ok as not yet loaded translations
// allow keys to be phrases having `:`, `.`
keySeparator: false,
nsSeparator: false,
Add that to your i18n.js inside i18n.use(LanguageDetector).init({})
Documentation https://www.i18next.com/principles/fallback#key-fallback
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With