From 2fc793096a9f91a5ff8b9313ad68fc4bbc7873da Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 25 Jun 2014 11:49:47 +0200 Subject: [PATCH] Use the preferred language sent by the browser, not the configured one refs #6074 --- .../Icinga/Application/ApplicationBootstrap.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index bb530ce29..d1328be15 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -471,26 +471,27 @@ abstract class ApplicationBootstrap /** * Setup internationalization using gettext * - * Uses the language defined in the global config or the default one + * Uses the preferred language sent by the browser or the default one * * @return self */ protected function setupInternationalization() { + $localeDir = $this->getApplicationDir('locale'); + if (file_exists($localeDir) && is_dir($localeDir)) { + Translator::registerDomain(Translator::DEFAULT_DOMAIN, $localeDir); + } + try { Translator::setupLocale( - $this->config->global !== null ? $this->config->global->get('language', Translator::DEFAULT_LOCALE) + isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) + ? Translator::getPreferredLocaleCode($_SERVER['HTTP_ACCEPT_LANGUAGE']) : Translator::DEFAULT_LOCALE ); } catch (Exception $error) { Logger::error($error); } - $localeDir = $this->getApplicationDir('locale'); - if (file_exists($localeDir) && is_dir($localeDir)) { - Translator::registerDomain(Translator::DEFAULT_DOMAIN, $localeDir); - } - return $this; } }