i18next use other namespaces
Unanswered
Morelet’s Crocodile posted this in #help-forum
Morelet’s CrocodileOP
Hello! i18next question, I have a weird behaviour where only keys available within the first listed namespace will be available, why is that?
I've imported the translation file which declares
There is no overlap, it just doesn't load the second one.
https://react.i18next.com/guides/multiple-translation-files
The docs is really unclear, it says I have to add to the useTranslation array, but I'm not clear on whether you ALSO need to add { ns: 'blabla'} or if it should be one or the other
Also it talks about "defined default namespace", is that the default namespace as configured in the config file, or is that the first namespace in the array?
My config
const { t, i18n } = useTranslation(["Global", "EconomicTab"]);
I've imported the translation file which declares
i18next.addResourceBundle("en", "EconomicTab", en);
at the top of the file which uses useTranslation. I've tried flipping the around and I get the opposite result, I can only resolve keys from EconomicTab and none from Global.There is no overlap, it just doesn't load the second one.
https://react.i18next.com/guides/multiple-translation-files
The docs is really unclear, it says I have to add to the useTranslation array, but I'm not clear on whether you ALSO need to add { ns: 'blabla'} or if it should be one or the other
Also it talks about "defined default namespace", is that the default namespace as configured in the config file, or is that the first namespace in the array?
import i18next from "i18next";
import { initReactI18next } from "react-i18next";
i18next.use(initReactI18next).init({
lng: document.documentElement.lang,
ns: [],
fallbackLng: "en",
resources: {},
defaultNS: "Global",
returnObjects: true,
partialBundledLanguages: true,
interpolation: {
escapeValue: true,
},
});
export default i18next;
My config
1 Reply
Morelet’s CrocodileOP
Apolgies if this post is a mess, I copied it over from Reactiflux :)