I18n: how can I trigger locale detection by code?
Unanswered
Mrigal carp posted this in #help-forum
Mrigal carpOP
When users opens my website, if they are logged in, I automatically redirect them to their user's locale.
With automatic local detection enabled, this leads sometimes to 2 redirections. For exemple / => /fr (because of browser's locale) => / (because of user's locale).
Having 2 successive redirections is not only ugly, it creates a random bug: sometimes the application is frozen (rehydration bug).
So, I disabled the automatic location detection (https://nextjs.org/docs/pages/building-your-application/routing/internationalization#disabling-automatic-locale-detection).
However, once I know the user is not logged in, I would like to redirect them depending on their browser's accepted languages. I did not find a way to do that programmatically in the docs, is there a way?
With automatic local detection enabled, this leads sometimes to 2 redirections. For exemple / => /fr (because of browser's locale) => / (because of user's locale).
Having 2 successive redirections is not only ugly, it creates a random bug: sometimes the application is frozen (rehydration bug).
So, I disabled the automatic location detection (https://nextjs.org/docs/pages/building-your-application/routing/internationalization#disabling-automatic-locale-detection).
However, once I know the user is not logged in, I would like to redirect them depending on their browser's accepted languages. I did not find a way to do that programmatically in the docs, is there a way?