mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
优化 多语言
This commit is contained in:
@@ -112,15 +112,15 @@ class Lang
|
||||
// 自动侦测设置获取语言选择
|
||||
if (isset($_GET[Config::get('lang_detect_var')])) {
|
||||
// url中设置了语言变量
|
||||
$langSet = $_GET[Config::get('lang_detect_var')];
|
||||
\think\Cookie::set('think_language', $langSet, 3600);
|
||||
$langSet = strtolower($_GET[Config::get('lang_detect_var')]);
|
||||
\think\Cookie::set(Config::get('lang_cookie_var'), $langSet, 3600);
|
||||
} elseif (\think\Cookie::get(Config::get('lang_cookie_var'))) {
|
||||
// 获取上次用户的选择
|
||||
$langSet = \think\Cookie::get(Config::get('lang_cookie_var'));
|
||||
$langSet = strtolower(\think\Cookie::get(Config::get('lang_cookie_var')));
|
||||
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
// 自动侦测浏览器语言
|
||||
preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches);
|
||||
$langSet = $matches[1];
|
||||
$langSet = strtolower($matches[1]);
|
||||
\think\Cookie::set(Config::get('lang_cookie_var'), $langSet, 3600);
|
||||
}
|
||||
if (in_array($langSet, \think\Config::get('lang_list'))) {
|
||||
|
||||
Reference in New Issue
Block a user