Closed forhadakhan closed 1 month ago
The implementation of setLocale
really depends on how you want to manage the locale in your app. It can be a cookie, a setting in the user profile, etc.
If it's a cookie, you can use the approach shown in example-app-router-without-i18n-routing—this example works fine on Vercel.
I'll move this to a discussion since it's a usage question.
Is your feature request related to a problem? Please describe.
I tried using App Router setup without i18n routing and defined a local switcher following official example.
This solution worked fine in the local development environment but resulted in an error (Cookies can only be modified in a Server Action or Route Handler.
nextjs 14.2.13
) in the production environment on Vercel."Describe the solution you'd like
I think
next-intl
should have a direct utility to set the locale from both client and server components. Just as we can access the current locale usinggetLocale
in server oruseLocale
in client, there should be a similar feature for setting the locale.NOTE: If I'm missing something or if such solutions already exist, please point me to the direct solution.
Describe alternatives you've considered
Alternative solutions might vary from developer to developer. I am working on a way to address this, but it would be better if there were an official solution.