next-translate-routes: "No translate routes data found. next-translate-routes plugin is probably missing from next.config.js"
I keep getting this error although I followed all the basic steps. I can even see the debug log in the terminal with all the redirects and rewrites created by the plugin, but somehow I’m still getting this error.
What I did:
- Wrap you next config with the next-translate-routes plugin
// next.config.js
const { i18n } = require("./next-i18next.config");
const withTranslateRoutes = require("next-translate-routes/plugin")
module.exports = withTranslateRoutes({
pageExtensions: ["page.tsx", "page.ts", "page.jsx", "page.js"],
reactStrictMode: true,
eslint: {
ignoreDuringBuilds: true,
},
esModule: true,
images: {
domains: [
//...
],
},
i18n,
translateRoutes: {
debug: true,
},
});
- Define your routes
// _routes.json
{
"/": {
"en": "hi",
"es": "hola",
"pt-BR": "oi"
}
}
- Wrap you _app component with the withTranslateRoutes hoc
import { appWithTranslation } from "next-i18next";
import { wrapper } from "../redux";
import { withTranslateRoutes } from "next-translate-routes";
function MyApp({ Component, pageProps }: AppProps) {
/**/
return (
<>
<Component {...pageProps} />
</>
);
}
export default withTranslateRoutes(
appWithTranslation(wrapper.withRedux(MyApp))
);
What I get in terminal:
[next-translate-routes] - Redirects: [
{
source: '/pt-BR/(hi|hola)/downloads/',
destination: '/oi/downloads/',
locale: false,
permanent: false
},
{
source: '/en/(oi|hola)/downloads/',
destination: '/en/hi/downloads/',
locale: false,
permanent: false
},
...
]
[next-translate-routes] - Rewrites: [
{
source: '/(oi|hi|hola)/downloads/',
destination: '/downloads/'
},
{
source: '/(oi|hi|hola)/about/',
destination: '/about/'
},
...
]
And eventually:
Error: [next-translate-routes] - No translate routes data found. next-translate-routes plugin is probably
missing from next.config.js
at withTranslateRoutes (\node_modules\next-translate-routes\react\withTranslateRoutes.js:63:15)
at eval (webpack-internal:///./src/pages/_app.page.tsx:71:140)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
I have searched for other issues here and in Google, but haven’t find anything similar. What am I missing?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15
I had the same issue. After many unsuccessful tries to fix this, I installed v.1.7.2 instead of the latest release and now it’s working fine. I’m on Nextjs version 11.1.2 with Preact 10.5.14.