add detection for Accept-Language

This commit is contained in:
printempw 2016-12-30 12:43:59 +08:00
parent cbec1d3869
commit e0a4667cc8
12 changed files with 5 additions and 3 deletions

View File

@ -16,9 +16,11 @@ class Internationalization
session(['locale' => Cookie::get('locale')]);
}
if (Session::has('locale') && Arr::exists(config('locales'), session('locale'))) {
if (Session::has('locale')) {
// Set app locale dynamically
App::setLocale(session('locale'));
} else {
App::setLocale($request->getPreferredLanguage());
}
return $next($request);

View File

@ -74,7 +74,7 @@ return [
|
*/
'locale' => 'zh-CN',
'locale' => 'zh_CN',
/*
|--------------------------------------------------------------------------

View File

@ -9,6 +9,6 @@ return [
| Available Languages
|
*/
'zh-CN' => '简体中文',
'zh_CN' => '简体中文',
'en' => 'English'
];