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

Language negotiation does not support the standard format for country codes (hyphen) #506

Closed
erdmenchen opened this issue Nov 6, 2017 · 3 comments

Comments

@erdmenchen
Copy link

Browsers usually send the Accept-Language-Header with country code in the hyphen notation e.g. de-DE, but the language negotiator only matches against de_DE in the current version of the config file.

if ( (isset($locale['regional']) && $locale['regional'] == $key) || (isset($locale['lang']) && $locale['lang'] == $key) ) {

In the current version of the config file all country aware languages are formatted with the underscore character.

//'de' => ['name' => 'German', 'script' => 'Latn', 'native' => 'Deutsch', 'regional' => 'de_DE'],

This results in a bad match and the requested language de-DE is not set because it does not match de and it does not match de_DE.

@ansata2001
Copy link
Contributor

Also, there is no the "lang" property in any line of the the bundled config.php https://github.com/mcamara/laravel-localization/blob/master/src/config/config.php although the languageNegotiator is trying to check if it matches with the key. Maybe it makes sense to to add the "lang" property on the fly when doing the negotiation, taking the Locale::canonizalize() of the key? If the property is not set manually.

@ansata2001
Copy link
Contributor

There was an accepted pull request addressing this issue: #507

@erdmenchen
Copy link
Author

Thank you very much @ansata2001.
I have not yet tested your fix, but it looks promising what I see in the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants