Merge branch 'master' into bugfix/logout-external-8626

This commit is contained in:
Eric Lippmann 2015-03-11 21:55:52 +01:00
commit ac2522af20
1 changed files with 11 additions and 7 deletions

View File

@ -307,20 +307,24 @@ class Web extends ApplicationBootstrap
/** /**
* Setup internationalization using gettext * Setup internationalization using gettext
* *
* Uses the preferred user language or the configured default and system default, respectively. * Uses the preferred user language or the browser suggested language or our default.
* *
* @return self * @return string Detected locale code
*
* @see Translator::DEFAULT_LOCALE For the the default locale code.
*/ */
protected function detectLocale() protected function detectLocale()
{ {
$auth = Manager::getInstance(); $auth = Manager::getInstance();
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$auth->isAuthenticated() if ($auth->isAuthenticated()
|| ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) === null && ($locale = $auth->getUser()->getPreferences()->getValue('icingaweb', 'language')) !== null
) { ) {
$locale = Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']); return $locale;
} }
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
return $locale; return Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
}
return Translator::DEFAULT_LOCALE;
} }
/** /**