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

Bug: negotiateLocale bug in Safari with fr-ca locale #2774

Closed
includebeer opened this issue Mar 29, 2020 · 0 comments · Fixed by #2872
Closed

Bug: negotiateLocale bug in Safari with fr-ca locale #2774

includebeer opened this issue Mar 29, 2020 · 0 comments · Fixed by #2872
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@includebeer
Copy link

I have set the parameter negotiateLocale = true in app/Config/app.php
The problem is request->getLocale() doesn't always return the right locale.

In Chrome the language is set to french first, then english, and it's working as expected, getLocale return "fr":

request->getUserAgent() = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36
request->getHeaderLine('accept-language') = fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7
request->getLocale()                      = fr

But in Safari, it's only set to french and getLocale return "en":

request->getUserAgent() = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15
request->getHeaderLine('accept-language') = fr-ca
request->getLocale()                      = en

This is on macOS 13.15.3 (Catalina) with CodeIgniter 4.0.2, PHP 7.4.2.
The supported languages are set to ['en', 'fr'].

My guess is there's a bug in the class Negotiate when parsing the accept-language header. The expected behavior would be that getLocale() return "fr" when accept-language is set to "fr-ca". But it looks like it doesn't recognize "fr-ca" as valid, and fall back to "en".

@includebeer includebeer added the bug Verified issues on the current code behavior or pull requests that will fix them label Mar 29, 2020
lonnieezell added a commit that referenced this issue Apr 23, 2020
Better locale matching against broad groups. Fixes #2774
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant