mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 22:04:25 +02:00
Web: Detect preferred locale using ipl-i18n
This commit is contained in:
parent
86614ad7a8
commit
db1fea6331
@ -496,9 +496,7 @@ class Web extends EmbeddedWeb
|
|||||||
*
|
*
|
||||||
* Uses the preferred user language or the browser suggested language or our default.
|
* Uses the preferred user language or the browser suggested language or our default.
|
||||||
*
|
*
|
||||||
* @return string Detected locale code
|
* @return string Detected locale code
|
||||||
*
|
|
||||||
* @see Translator::DEFAULT_LOCALE For the default locale code.
|
|
||||||
*/
|
*/
|
||||||
protected function detectLocale()
|
protected function detectLocale()
|
||||||
{
|
{
|
||||||
@ -508,9 +506,14 @@ class Web extends EmbeddedWeb
|
|||||||
) {
|
) {
|
||||||
return $locale;
|
return $locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var GettextTranslator $translator */
|
||||||
|
$translator = StaticTranslator::$instance;
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||||
return Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
return (new Locale())->getPreferred($_SERVER['HTTP_ACCEPT_LANGUAGE'], $translator->listLocales());
|
||||||
}
|
}
|
||||||
return Translator::DEFAULT_LOCALE;
|
|
||||||
|
return $translator->getDefaultLocale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user