Change locale and stay on the same route
See original GitHub issueHi,
I tried to change the locale and stay on the same route by following nextjs exemple.
const router = useRouter()
const { pathname, asPath, query } = router
// change just the locale and maintain all other route information including href's query
router.push({ pathname, query }, asPath, { locale: nextLocale })
Unfortunately I have a typescript error with nextjs-routes.
I fixed it with an assertion any but maybe you have a better solution?
Thanks for your help!
Issue Analytics
- State:
- Created 10 months ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Rails locale changing but paths in links stay the same
I would like to when I click the link to change locale, everything in the page changes including the paths. Currently it only...
Read more >Locales are not loaded if Shallow Routing · Issue #518 - GitHub
Hi, In order to change the location and maintain the app state and the current path (Change language while staying on the same...
Read more >Multi-language routing in React - Prototyped
Find out how to create a Localized React Router with support for multiple languages that will redirect your users to correct routes.
Read more >Advanced Features: Internationalized Routing - Next.js
Next.js has built-in support for internationalized (i18n) routing since v10.0.0 . You can provide a list of locales, the default locale, and domain-specific ......
Read more >A Comprehensive Guide to Rails Internationalization (i18n)
Simply put, it is an opportunity to stay on the same page with people of ... Let's start with our routes; we will...
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
Hi, I think it’s because I have a “catching all” page. […slug].tsx
Can you try this one? I’ve reproduced the error here. https://stackblitz.com/edit/nextjs-zmkzrf?file=pages/_app.ts
Thanks! #97 fixed!