how to use the NEXT_LOCALE
See original GitHub issuehello, I need to persist the change when somebody goes to /en route or click
# placed in components/header.tsx
# href is empty so would not change the page, but when we move to
# another page it will be back to default, how to persist so it would only
# change when we click another locale="otherlang" ?
<Link href="" locale="en" key="en">
{t(`common:menuchangetodefaultinheader`)}
</Link>
they should persist until anybody change the default language is there an example on how to use the next_locale in a nextjs project? where should it be placed? how do you guys use cookie or NEXT_lOCALE?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Advanced Features: Internationalized Routing - Next.js
By using domain routing you can configure locales to be served from different domains: // next.config.js module.exports = { i18n: { locales: ['en-US',...
Read more >Next.js: Adding Localization with Next-Intl - This Dot Labs
Adding locales to a project in NextJs is as easy as creating a few files, and installing the handy npm package next-intl ....
Read more >How to access the current i18n locale in an API route? #21798
I used to be able to use req.query.__nextLocale , but is not available anymore after 10.0.5. Tried to check cookies, try to import...
Read more >Localizing Your Next.js App - Smashing Magazine
Create valid ones using locale code and/or country codes and stick with lower-case because they will generate a url soon. Now your app...
Read more >How to access locale in custom app on server-side in Next.js?
You can access the locale in your custom app's getInitialProps through the router prop. static async getInitialProps({ Component, ctx, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This should be on the README, thanks a lot
@BjoernRave, this is part of Next.js, not Next-translate:
https://nextjs.org/docs/advanced-features/i18n-routing#leveraging-the-next_locale-cookie
Next-translate since version 0.19 uses the i18n routing of Next.js, and all the logic is exactly the same as Next.js. The only new logic that Next-translate introduces now is to inject code inside the loaders (getStaticProps, getServerSideProps…) to download the translations that each page needs according to the current language.
By this, I mean that the reason why by default is so, it’s something that wasn’t discussed here in the library. Surely any suggestions on routing are best addressed to @timneutkens’s RFC.