在实现 Laravel 自带语言包自动切换功能时中文语言包不识别?
切换语言包按钮时 进行设置语言
public function set_lang(Request $request){
$lang = $request->lang;
\App::setLocale($lang);
$res = $request->session()->put('language',$lang);
$seccess = array(
'code'=>200,
'data'=> \App::getLocale('language')
);
return response()->json($seccess);
}
<h2 class="listTitle">—— {{ trans('ohi.latest_ohi_inter') }} ——</h2>
语言包都是存在的字段也存在
结果:
我的config/app中的设置
'locale' => 'en',
/*
|--------------------------------------------------------------------------
| Application Fallback Locale
|--------------------------------------------------------------------------
|
| The fallback locale determines the locale to use when the current one
| is not available. You may change the value to correspond to any of
| the language folders that are provided through your application.
|
*/
'fallback_locale' => 'zh_CN',
推荐文章: