Skip to content
Discussion options

You must be logged in to vote

I was saving the chosen language in localStorage along with all other user settings.

But already found a solution that I was not expecting. Instead of using the "without i18n routing" configuration, I used the "i18n routing" configuration. I think it's easier, and just set the localePrefix = "never".

For switching language on the client side, I handled it this way:

  function onSelectChange(event: ChangeEvent<HTMLSelectElement>) {
    const nextLocale = event.target.value;
    Cookies.set("NEXT_LOCALE", nextLocale);
    router.refresh();
  }

At the end result looks the same i was searching 🤷‍♂️

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bryanlundberg
Comment options

Answer selected by bryanlundberg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants