next-translate icon indicating copy to clipboard operation
next-translate copied to clipboard

The locale doesn't change for pages other than index page

Open fr-irene opened this issue 4 years ago • 13 comments

I tried using next-translate v1.0.7 Using the sub path /ja

it works for index page localhost:3000/ja, but not working when navigating to other page, it keeps returning to default en locale localhost:3000/ja/product/detail

ready - started server on http://localhost:3000
next-translate - compiled page: /product/detail - locale: en - namespaces: common - used loader: getInitialProps
next-translate - compiled page: / - locale: ja - namespaces: common - used loader: getStaticProps

fr-irene avatar May 26 '21 06:05 fr-irene

You need to update to the last version of Next.js. Should be fixed after this PR https://github.com/vercel/next.js/pull/21930.

Try Next.js 10.2.3 😊

aralroca avatar May 26 '21 10:05 aralroca

I too have this issue, even after updating to latest version of react, and next-translate.

Gyaniultimate avatar Jul 08 '21 15:07 Gyaniultimate

Upgrade to nextjs 10.2.3 solved my issue

choo737 avatar Aug 26 '21 09:08 choo737

@Gyaniultimate after migrate Next.js solve it?

aralroca avatar Sep 06 '21 13:09 aralroca

@aralroca I have a same issue but upgrade next.js to 10 cannot solve it.

The locale language can only be detected when I entered the website for the first time. When the page changed by using Router.push, the locale language keep showing the defaultLocale that sets in config file.

Also, I tried to set NEXT_LOCALE into cookie, the value is correct but the pages keep getting the wrong defaultLocale.

peggy1000423 avatar Oct 06 '21 08:10 peggy1000423

@peggy1000423 can try to use specifically this version 10.2.3

choo737 avatar Oct 07 '21 06:10 choo737

I'm experiencing the same issue with next 12.0.7 and next-translate 1.2.0. For the index page the browser gets redirected to the correct locale prefix. For subpages this does not happen.

Update:

defaultLocale: "en" Browser-Language: "de"

  • domain.tld --- redirects to ---> domain.tld/de
  • domain.tld/imprint delivers version with default locale

faaaaabi avatar Jan 09 '22 20:01 faaaaabi

Check if you are using Link from next/link. I had the same problem but it was using link from Material Ui which overrides locales.

molimat avatar Feb 22 '22 18:02 molimat

This still seems to be an issue in v12.1.4

MarkMurphy avatar Apr 09 '22 00:04 MarkMurphy

Any news of this? I can confirm that the issue is there in the latest version of NextJS. If I directly go to a particular route, it does not redirect to the specific locale page but rather go to the page for the default locale. I tried to play around with the middleware but that is no help either as the request object does any information on the right locale. It would be great if you could at least provide a direction how to fix this issue in case the bug is not already fixed.

Thanks a lot in advance.

sanesanyo avatar Sep 06 '22 12:09 sanesanyo

With NextJS 13, my middleware works fine under development environment while not trigger at all under production environment...

james104 avatar Dec 07 '22 01:12 james104

Still have this issue under dev environment with NEXT_LOCALE set. Package versions:

├── [email protected]
├── [email protected]

black197 avatar Sep 12 '23 04:09 black197

Did anyone figure out how to fix this? I'm having the same issue

ljk1291 avatar Oct 15 '23 00:10 ljk1291