Change getLangFromHTTP()
For the header ACCEPT_LANGUAGE, which does not contain a separate code for the main part of the language.
This commit is contained in:
parent
34fddd45e4
commit
2cdcd19568
1 changed files with 10 additions and 1 deletions
|
@ -259,15 +259,24 @@ class Current extends Action
|
|||
{
|
||||
if (! empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||
$langs = $this->c->Func->getLangs();
|
||||
$main = [];
|
||||
foreach ($this->c->Func->langParse($_SERVER['HTTP_ACCEPT_LANGUAGE']) as $entry) {
|
||||
$arr = \explode('-', $entry);
|
||||
$arr = \explode('-', $entry, 2);
|
||||
if (isset($arr[1])) {
|
||||
$entry = $arr[0] . '_' . \strtoupper($arr[1]);
|
||||
$main[] = $arr[0];
|
||||
}
|
||||
if (isset($langs[$entry])) {
|
||||
return $langs[$entry];
|
||||
}
|
||||
}
|
||||
if (! empty($main)) {
|
||||
foreach ($main as $entry) {
|
||||
if (isset($langs[$entry])) {
|
||||
return $langs[$entry];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->c->config->o_default_lang;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue