Closed sajjadramezani73 closed 10 months ago
Hi! This is probably because your browser language is set to English. The i18nRouter
function in your middleware redirects visitors to their preferred language based on the accept-language
header on the request. If your browser language is not set to English, please check that you do not accidentally have the NEXT_LOCALE cookie set.
This is expected behavior is your browser language is English. If you don't want automatic locale detection, you can change the localeDetector
config option to false
.
Thank you This item worked
Great!
Hi, I have a question regarding the same topic, so just not to open a new ticket.
I'm trying to implement localization for output: "export"
based on SSG
section from this tutorial: https://i18nexus.com/tutorials/nextjs/react-intl
It does generate routes for locales, but It seems that defaultLocale
isn't respected in this case. I.e. my expectations that localhost:3000/myPath
will be working (based on prefixDefault
behavior), but at the moment only localhost:3000/en/myPath
option is working. I guess this means that the "no locale" version should be generated during the build as well.
Is it something I can easily handle?
I guess I can just put a copy of the pages outside [locale]
to achieve this, but not sure that this is how it should be.
@Lighttree Unfortunately this library cannot be used with output: "export"
. This library depends heavily on middleware, redirects, and rewrites, all of which are not supported by output: "export"
. You can read more about this here: https://nextjs.org/docs/app/building-your-application/deploying/static-exports#unsupported-features
@i18nexus Isn't it working, but with the same limitations that are described here: https://next-intl-docs.vercel.app/docs/routing/middleware#usage-without-middleware-static-export ? I mean I'm able to get the correct build. Maybe I'm missing something.
@Lighttree It looks like it will build, but when running npm run dev
you will see an error.
If you were to use this library with output: 'export'
:
prefixDefault
is set to true
. Since we can't use rewrites, the locale always has to be present in the pathname./en
(or whatever your default locale is) or else /
will return a 404.If you do the 3 things above, you might as well uninstall this library because it won't be doing anything at all. You just need react-intl
and the [locale]
dynamic segment.
This being said, it is worth us taking a look at how we can support output: 'export'
. I'm guessing it would look something like having a script that runs before build that copies the contents of the [locale]
directory into app
. Other changes would obviously have to be made, but I think that would be the basic strategy.
hi I have used this package in the next 13.4 app router project
config for i18n with persian and turkey and english language and defaulLocale equal fa const i18nConfig: Config = { locales: ['fa', 'tr', 'en'], defaultLocale: 'fa', prefixDefault: true, };
why after the implementation of the project localhost:4200/en it opens?