// Installer now use the browser language as default language (with HTTP_ACCEPT_LANGUAGE var)
This commit is contained in:
1 parent
0efa225fcc
commit
e304a8710e
1 file changed
+20
-1
@@ -174,7 +174,7 @@ abstract class InstallControllerHttp
|
|||||||
|
|
||||||
// Set current language
|
// Set current language
|
||||||
$this->language = InstallLanguages::getInstance();
|
$this->language = InstallLanguages::getInstance();
|
||||||
$lang = (isset($this->session->lang)) ? $this->session->lang : 'en';
|
$lang = (isset($this->session->lang)) ? $this->session->lang : $this->detectLanguage();
|
||||||
if (!in_array($lang, $this->language->getIsoList()))
|
if (!in_array($lang, $this->language->getIsoList()))
|
||||||
$lang = 'en';
|
$lang = 'en';
|
||||||
$this->language->setLanguage($lang);
|
$this->language->setLanguage($lang);
|
||||||
@@ -390,6 +390,25 @@ abstract class InstallControllerHttp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function detectLanguage()
|
||||||
|
{
|
||||||
|
// This code is from a php.net comment : http://www.php.net/manual/fr/reserved.variables.server.php#94237
|
||||||
|
$split_languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||||
|
if (!is_array($split_languages))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach ($split_languages as $lang)
|
||||||
|
{
|
||||||
|
$pattern = '/^(?P<primarytag>[a-zA-Z]{2,8})'.
|
||||||
|
'(?:-(?P<subtag>[a-zA-Z]{2,8}))?(?:(?:;q=)'.
|
||||||
|
'(?P<quantifier>\d\.\d))?$/';
|
||||||
|
if (preg_match($pattern, $lang, $m))
|
||||||
|
if (in_array($m['primarytag'], $this->language->getIsoList()))
|
||||||
|
return $m['primarytag'];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function &__get($varname)
|
public function &__get($varname)
|
||||||
{
|
{
|
||||||
if (isset($this->__vars[$varname]))
|
if (isset($this->__vars[$varname]))
|
||||||
|
|||||||
Reference in new issue
Block a user