Hi, I'm using react-i18next ^7.5.0.
I'm not using json files but directly injecting an object in options (you can see them below). This works fine on some computers, on some others I get this:
i18next::translator: missingKey it-IT app language_lable.it-IT language_label.itIT
My guess is that somehow languageOnly option isn't working.
Here my config.
import i18n from "i18next";
import Backend from "i18next-xhr-backend";
import LanguageDetector from "i18next-browser-languagedetector";
import { reactI18nextModule } from "react-i18next";
import en from "./locales/en";
import it from "./locales/it";
i18n
.use(Backend)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
.use(Backend)
.use(LanguageDetector)
.use(reactI18nextModule)
.init({
fallbackLng: "en",
ns: ["app"],
defaultNS: "app",
debug: true,
interpolation: {
escapeValue: false
},
load: "languageOnly",
react: {
wait: true,
bindI18n: "languageChanged loaded",
bindStore: "added removed",
nsMode: "default"
},
resources: {
en: en,
it: it
}, err => {console.error(err)})
looks more like you construct a key strange -> missing key is language_lable.it-IT which does not exist i guess as the key should be language_lable.it right?
load language only option does only affect loading via backend...nothing todo with language detection:
so if user language is it-IT: it will still try to lookup in it-IT -> it -> en
i18next.language will always be detected language. So you will have to proper construct you key by splitting by - -> i18next.t('language_lable.' + i18next.language.split('-')[0])
I was guessing that was something similar. Wouldn't be better if language detection was consistent with backend? Anyway I'll fix it the way you suggested. Thank you for the quick response. 馃憤
there is i18next.languages which is an array of languages used in the lookup process it-IT -> it -> en
there is also option whitelist in init...to set which languages are allowed
Cool, I'll manage to work around the issue with those helpers then.
Most helpful comment
looks more like you construct a key strange -> missing key is
language_lable.it-ITwhich does not exist i guess as the key should belanguage_lable.itright?load language only option does only affect loading via backend...nothing todo with language detection:
so if user language is it-IT: it will still try to lookup in
it-IT->it->eni18next.language will always be detected language. So you will have to proper construct you key by splitting by
-->i18next.t('language_lable.' + i18next.language.split('-')[0])