Skip to content

Commit

Permalink
调整header方式和cookie自动识别多语言的优先级
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Jun 26, 2020
1 parent 3709848 commit eaf6e6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/think/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ public function detect(Request $request): string
if ($request->get($this->config['detect_var'])) {
// url中设置了语言变量
$langSet = strtolower($request->get($this->config['detect_var']));
} elseif ($request->cookie($this->config['cookie_var'])) {
// Cookie中设置了语言变量
$langSet = strtolower($request->cookie($this->config['cookie_var']));
} elseif ($request->header($this->config['header_var'])) {
// Header中设置了语言变量
$langSet = strtolower($request->header($this->config['header_var']));
} elseif ($request->cookie($this->config['cookie_var'])) {
// Cookie中设置了语言变量
$langSet = strtolower($request->cookie($this->config['cookie_var']));
} elseif ($request->server('HTTP_ACCEPT_LANGUAGE')) {
// 自动侦测浏览器语言
$match = preg_match('/^([a-z\d\-]+)/i', $request->server('HTTP_ACCEPT_LANGUAGE'), $matches);
Expand Down

0 comments on commit eaf6e6d

Please sign in to comment.