Closed yzmp closed 1 year ago
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.
Just upped the version incrementally and it seems like v. 1.8.0-1 is the latest version that still works for me. So 1.8.0-2 seems to be the issue in my case, or the following commit: https://github.com/hozana/next-translate-routes/commit/8bfee0f14f05e0b35e1e705711ff980e5e3e551d
any idea @cvolant ?
Thank you both for reporting the issue. Having identified the precise version that introduced the bug is a great help. I will look at it as soon as I can.
Hi, I have the same issue, but my problem is little difference, because I use NX monorepo, and if I want to work next-translate in this monorepo I must add env variable NEXT_TRANSLATE_PATH=apps/projectName
I think there is similar problem for me. Is there any variable where I can set up this? My error is Error: [next-translate-routes] - No pages folder found.
Currently working on this issue... @yzmp, @simonhenke, ...
_app
file? Something like /pages/_app.js
...@krystianjj your problem is different: what you are looking for is probably the pageDirectory
config.
In next.config.js
:
translateRoutes: {
pageDirectory: 'apps/projetName',
}
See the configuration section in the docs.
Currently working on this issue... @yzmp, @simonhenke, ...
- Are you on Windows?
- Could you give me the path to you
_app
file? Something like/pages/_app.js
...
@cvolant:
@krystianjj your problem is different: what you are looking for is probably the
pageDirectory
config. Innext.config.js
:translateRoutes: { pageDirectory: 'apps/projetName', }
See the configuration section in the docs.
@cvolant Unfortunately this did not solve the problem. I want to use your packege with this framework -> https://nx.dev/
@yzmp I suspect that it comes from slashes in paths: \
on Window and /
on Linux.
I released next-translate-routes@1.9.0-3 yesterday, and it includes a fix for this issue: could you try it and tell me if it works?
@krystianjj I never used Nx yet: I tried to create a workspace to check the filetree, but it is standard Next.js file tree. Do you have this filetree too ?
root/
├─ ...
├─ apps/
│ ├─ next-app/
│ │ ├─ ...
│ │ ├─ next.config.js
│ │ ├─ pages/
│ │ │ ├─ _app.js // or app.tsx or else
│ │ │ ├─ ...
If you are on Windows, then it is probably the problem describe in my previous comment: could you try next-translate-routes@1.9.0-3 too?
@cvolant I'm also on Windows and the path is /pages/_app.page.tsx
.
I'm excited to try out the new version (probably tomorrow), I'll let you know if it helped :) Thanks!
@cvolant On 1.9.0-3, when I start the app, I now get the following error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
at Object.readdirSync (fs.js:1038:10)
at getAllRoutesFiles (C:\Users\...\node_modules\next-translate-routes\plugin\routesFiles.js:46:39)
@simonhenke could you try the latest version? next-translate-routes@1.9.1
@cvolant I'm still getting the same error (ERR_INVALID_ARG_TYPE
). In our project we currently have a branch on which we updated to Next12. I'll test the latest version of this lib there as well, maybe that works.
@cvolant Seems to work on Next12, nice! :)
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:
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, }, });
// _routes.json { "/": { "en": "hi", "es": "hola", "pt-BR": "oi" } }
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)) );
[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/' }, ... ]
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 ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)