douxi1968 2015-10-28 13:49
浏览 61

如何在用户设置中设置强制区域设置否决浏览器检测到的区域设置 - laravel

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向