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

How to fallback to language code if country code is not in supported locales? #505

Open
erdmenchen opened this issue Nov 6, 2017 · 6 comments

Comments

@erdmenchen
Copy link

erdmenchen commented Nov 6, 2017

I have the following issue (maybe a configuration issue?):
I have en defined in the supported locales and default language set to de.
useAcceptLanguageHeader is set to true.

When browser requests en-US via Accept-Language-Header, the de locale is set.
How to specify, that it should fall back to en if en-US is not available?

@Daidalos117
Copy link

Daidalos117 commented Jun 11, 2018

Did you solve this? So simple thing and I cant figure out how to do it.

@Daidalos117
Copy link

Nothing? Noone? So basic funcionality and noone solved this?

@Nuranto
Copy link

Nuranto commented Sep 24, 2018

Same question here oO
I agree, it's the base, should be native ? oO

@iwasherefirst2
Copy link
Collaborator

iwasherefirst2 commented Oct 19, 2019

When browser requests en-US via Accept-Language-Header, the de locale is set.
How to specify, that it should fall back to en if en-US is not available?

A browser usually has multiple languages set with different ranking values, so I am not sure if this is a realistic case, that a browser language has en-US as priority and not en at all.

However, adding this functionality to Accept-Language-Header method should't be a problem. Maybe we should make this general rule, whenever a language like xx-yy is requested, check at the end if xx is available. For example, if a browser has en-US(priority 1) and es(priority 0.7) then add en with lowest priority.

@ruanpepe
Copy link

The laravel/framework 7.21.0 implements an App::setFallbackLocale method.
This is easier now.

@ruanpepe
Copy link

@iwasherefirst2 Can you take a look at that pull request? Maybe this is the solution. #731

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

No branches or pull requests

5 participants