laravel-localization
laravel-localization copied to clipboard
How to fallback to language code if country code is not in supported locales?
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?
Did you solve this? So simple thing and I cant figure out how to do it.
Nothing? Noone? So basic funcionality and noone solved this?
Same question here oO I agree, it's the base, should be native ? oO
When browser requests
en-US
via Accept-Language-Header, thede
locale is set. How to specify, that it should fall back toen
ifen-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.
The laravel/framework 7.21.0 implements an App::setFallbackLocale method. This is easier now.
@iwasherefirst2 Can you take a look at that pull request? Maybe this is the solution. #731