-
-
Notifications
You must be signed in to change notification settings - Fork 343
Description
Description
Based on the docs, the main strategy to detect the locale is:
- A locale prefix is present in the pathname (e.g. /de/about)
- A cookie is present that contains a previously detected locale
- The
accept-language headeris matched against the available locales - The
defaultLocaleis used
This happens very well when accessing a browser by URL.
But the strategy fails if I access my app, which is a PWA, from installed on mobile.
The NEXT_LOCALE cookie is resetting when the app opens based on the accept-language header, even if I have this cookie value already.
Debugging my phone
If I access the root URL /, the previous NEXT_LOCALE is ignored. The locale is always en because I'm using it as the default language on my phone.
There is no problem with the app, only the NEXT LOCALE cookie is resetting. Other cookies are preserved and retrieved. In case I change my cellphone locale to Portuguese, the cookie is always pt no matter what.
Important
"next": "14.1.0""next-intl": "3.5.1""@serwist/next': '8.4.3"'@serwist/sw': '8.4.3'- It was tested with 2 Android phones with Chrome with the same result.
- Before some
next-intlupdate (I don't know which version) it did not happen.
Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://github.com/maiconsanson/next-intl-pwa-ignoring-cookie
Reproduction description
Steps to reproduce:
- Configure your mobile device to the English locale
en. - Install the PWA (mobile) on Chrome.
- Open the app and change the locale by clicking on the link "Mude para Português".
- Close the PWA.
- Open the app again and notice that the locale is
en, not the previousptselected.
Repeat these steps directly on the browser and you seed that works normally.
Here is the production link to see in action:
https://intl-unable-find-locale.vercel.app/
Expected behaviour
The expected behavior is that the saved NEXT_LOCALE cookie value be used to define language when the PWA is installed.