I have developed a react application where I am using i18next, react-i18next, i18next-http-backend for localization.
In my application, I wanted to support only en-us language code for now and maybe will add further languages in the future, so I have added the below settings for i18n configuration.
import i18n from "i18next";
import backend from "i18next-http-backend";
import { initReactI18next } from "react-i18next";
i18n
.use(backend)
.use(initReactI18next)
.init({
lng: "en-us",
fallbackLng: "en-us",
debug: true,
supportedLngs: ["en-us"],
lowerCaseLng: true,
interpolation: {
escapeValue: false,
formatSeparator: ","
}
});
export default i18n;
and placed the localization translation file at public/locales/en-us/translation.json. I have added supportedLngs because I want my i18next-http-backend should load only supported languages.
When I run the application I am getting a below warning
i18next::languageUtils: rejecting language code not found in supportedLngs: en
As per the document here: https://www.i18next.com/overview/configuration-options
I have also tried to set the nonExplicitSupportedLngs: true but then my translation file is not loaded and I am getting another weird warning as below:
i18next::languageUtils: rejecting language code not found in supportedLngs: en-us
i18next::languageUtils: rejecting language code not found in supportedLngs: en
How I can get away from the warning? am I missing something?
Thanks in Advance
Try to set the load option to “currentOnly” https://www.i18next.com/overview/configuration-options#languages-namespaces-resources