how to handle getting too many warning in console for i18n setup

3.2k views Asked by At

i18n setup-

import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import { langResources } from "./locales/langResources";

const resources = langResources;
i18n

  .use(initReactI18next)

  .init({
    resources,
    fallbackLng: "en_us",
    debug: true,

    interpolation: {
      escapeValue: false,
    },
    react: {
      wait: true,
      useSuspense: false,
    },
  });

export default i18n;

warnings-

`i18next: init: no languageDetector is used and no lng is defined.

react-i18next:: i18n.languages were undefined or empty undefined.

i18next: hasLoadedNamespace: i18n.languages were undefined or empty undefined.

i18next::translator: key "Action_Center" for languages "en_us" won't get resolved as namespace "translation" was not yet loaded This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`

1

There are 1 answers

0
Sarfraj Ansari On

adding lng:"en_us" removes all the warning