Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Accept locale with useRouter APIs #409

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Conversation

amannn
Copy link
Owner

@amannn amannn commented Jul 17, 2023

Closes #408
Ref #407, #320

@vercel
Copy link

vercel bot commented Jul 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
example-next-13-next-auth ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2023 6:55am
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2023 6:55am
next-intl-example-next-13 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2023 6:55am

@WilliamZimmermann
Copy link

This works like a charm for App Router. How about for Pages Router?

I mean, I'm trying to follow the example on the page for migration Pages/App Router (https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration), but when it refers to links, it redirects for something like [locale]/myPage instead give the right locale. Any suggestion?

@amannn
Copy link
Owner Author

amannn commented Feb 6, 2024

The Pages Router has this built in.

@WilliamZimmermann
Copy link

Thanks Amann. So I should do something like this:

router.push("/", "", { locale: "en" });

I tested with your "example-app-router-migration" and it works fine. However, in our project (we are still migrating from Pages to App) it is not working.

In our project, the same "pattern" of URL is simple removing the "locale" from the URL instead to replace the [locale]. Probably some bad settings.

Thank you again for the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass a locale to navigation APIs from useRouter
2 participants