question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change locale and stay on the same route

See original GitHub issue

Hi,

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:closed
  • Created 10 months ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
groomaincommented, Nov 17, 2022

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

0reactions
groomaincommented, Nov 18, 2022

Thanks! #97 fixed!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found