优化 多语言

This commit is contained in:
huangdijia
2015-12-21 12:03:34 +08:00
parent 050735d8c9
commit a1184f4930

View File

@@ -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'))) {