-
-
Notifications
You must be signed in to change notification settings - Fork 760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial locale argument was not passed into serverSideTranslations #1091
Comments
Please post on StackOverflow for help. |
There should be answer to this. The stackoverflow thread of this query shows an answer but it is not accepted and I tried that way too but it didn't work. My nextjs app build is failing due to this |
This is the error I am getting on build
|
The error is self-explanatory: Initial locale argument was not passed into serverSideTranslationsIn @fuzunspm's case, they should double check what @AhsanNissar There may indeed be an issue with plugin composition here, but that is going to vary, case-by-case. |
This is my next-i18next.config.js code
and I just passed i18n in next.config.js by requiring it like this
The locale is not initialized when making a build but when runningg the application it takes into account the deaultLocale and works fine. |
@AhsanNissar If you believe as though you have found a bug in |
@AhsanNissar There is an issue about
|
@fuzunspm Fixing a bug starts with a reproducible example, which I have not yet seen. Thanks. |
your first reply was about directing me to stackoverflow and I can see many examples in the issues. Anyway, I already commented a workaround for the issue |
@fuzunspm My application is built with nextjs and not with reactjs so I do not need to add any workaround and according to example in this repo they are already using |
This comment has been minimized.
This comment has been minimized.
Thanks @AhsanNissar, let's continue discussion there. |
@fuzunspm maybe you need to see this https://stackoverflow.com/a/67066847/11746564 |
Hello everybody. I faced with this issue today during docker deployment. Please be sure that you copy your next.config.js and next-i18next.config.js in your docker container (or deployment service). If you missed next.config.js then next.js after deployment will use default settings without next-i18next.config.js and as result initial local will be undefined. I hope it helps some one. Happy coding. |
Thanks a lot, I got it working. I added these 2 lines according to your message:
|
Finally! Main issue is, even if you have default language is set, you have to render first page, index.js, with /en/index or /tr/index, or use routing to / instead of /index, after that everything works as expected |
Congrats. Unfortunately I don't understand what you're saying. Could you explain further what you've done to resolve this? In my case I'm not using i18n routing and have not modified next.config.js to include i18n. At this point I don't know where/how the locale.locale should be set and what the value of locale.locale should be. Ex. a string, an object, or...? |
locale is string. to solve my issue I had to replace all of my /index routers to / path |
Thanks a lot man. You saved my day |
For me, upgrading next to the latest version solved the issue. |
I update Next version or downgrade next-i18next solved the issue. |
I started having the issue since I added next-compose-plugins to be able to run bundle-analyzer along with i18next next.config.js
Things were working fine with this config:
Now I'm stuck for an hour trying to figure out what started to be missing to i18next. This is the error I get:
|
how to solve this problem |
This solution is right. And need to copy the next-i18next.config.js to the root directory for the project.
|
Hi @fuzunspm, I don't know if you still facing this issue or not, but I was getting the same error message, however I found that next/link component the one was making the bug. I was using it like this < Link href="/register" > , and I was able to solve it by converting it to this < Link href="/register"> after doing this the error not shown again, I think you can check this on your side. |
@Abdelrhmangad Thank you for your suggestion and reply. I eventually replaced this package with a custom made one but I will try it anyway on a test project. |
I had similar problem. Turns out the mechanism I was using wasn't appropriate. I wasn't using locale in the URL when it comes to the defaultLocale For example, my URLs are of type Further, in my configuration, I have declared
So, what was essentially happening was my
The fix I made was to involve
My packages are as follows
|
Describe the bug
It won't work after upgrading both i18next and nextjs. I'm getting
on index.js
Occurs in next-i18next version
"next-i18next": "^8.1.2",
OS (please complete the following information)
Additional context
next-i18next.config.js
next.config.js
_app.js
index.js
The text was updated successfully, but these errors were encountered: