Users of my app can set up their preferred locale in their settings panel. In my case it is pl
.
However, when I am using the app as a logged user on a browser which preference of locales does not contain pl
or has it below en
, I see english translations.
My problem: how make the browser observe the locale set by user? Or... how to force the app to switch to the user-preferred locale?
Note: I dont want the locale code to be displayed in the URLs.
Imagine this scenario:
(it happens to me very often) I sit in a net caffee in China. I am forced to use a browser with no Polish language defined ('pl') in the preference of languages in the browser's settings.
My app is switching the displayed languages to 'zw' or 'en'. In other words, the trans('messages.xxxx)
are translated into Chinese or English if I am lucky.
Even when I am logged and I have defined inside my Laravel app that my preffered locale is 'pl.
In my app and in config/app.php
I have defined all the above languages, and the fallback is to Polish.
'locale' => 'pl','en','es','de','zw-tw',
'available_language' => array('pl','en','es','de','zw-tw'),
'fallback_locale' => 'pl',
However, as the browser forces its own locale, the displayed translations are either inconsistent (somme are taken from fallback, some from Chinese)... and NONE from the language I desire to use when logged, which is pl
in the case of my user settings.