next-i18next was unable to find a user config

Viewed 2951

i was trying to add translation to my app, but i'm stuck on this error:

error - Error: next-i18next was unable to find a user config
    at _callee$ (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:196:19)
    at tryCatch (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/regenerator-runtime/runtime.js:63:40)
    at Generator.invoke [as _invoke] (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/regenerator-runtime/runtime.js:294:22)
    at Generator.next (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/regenerator-runtime/runtime.js:119:21)
    at asyncGeneratorStep (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
    at /media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/@babel/runtime/helpers/asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at /media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/@babel/runtime/helpers/asyncToGenerator.js:21:12
    at serverSideTranslations (/media/coyas/47B492C22544E4BA/TERRA_SYSTEM/software_center/iMedia/ZebraGroupe/zebraTravel/zebraTravelWebUI/node_modules/next-i18next/dist/commonjs/serverSideTranslations.js:259:17) {
  page: '/'
}

and i found no solution yet.

i18n.config.js

const path = require("path");

module.exports = {
    i18n: {
        locales: ["en", "fr", "pt"],
        defaultLocale: "pt"
    }
};

next.config.js

require("dotenv").config();
const { i18n } = require("./i18n.config");

module.exports = {
    env: {
        API_BASE_URL: process.env.API_BASE_URL,
        SiteKey: process.env.SiteKey,
        SecretKey: process.env.SecretKey
    },
    i18n
};

I'm using serverSideTranslations on almost every page except some componentsand pages.[id].

ex. on index.js

import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";

const Home = ({ expe }) => {
    //const islang = i18n.isInitialized;
    const { t } = useTranslation("common");
...
...
...
export const getStaticProps = async ({ locale }) => {
    //const obj = { namespacesRequired: ["common", "footer", "navbar"] };
    const res = await getExperiencias(2); //limite = 2
    const exp = await res.json();

    return {
        props: {
            ...(await serverSideTranslations(locale, [
                "common",
                "footer",
                "navbar"
            ])),
            expe: exp
        } // will be passed to the page component as props
    };
};

export default Home;

this is the link to github branch: https://github.com/Coyas/zebraTravelWebUI/tree/develupdate

link to i18n-next: https://github.com/isaachinman/next-i18next

0 Answers
Related