Use the preferred language sent by the browser, not the configured one
refs #6074
This commit is contained in:
parent
461b050718
commit
2fc793096a
|
@ -471,26 +471,27 @@ abstract class ApplicationBootstrap
|
||||||
/**
|
/**
|
||||||
* Setup internationalization using gettext
|
* 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
|
* @return self
|
||||||
*/
|
*/
|
||||||
protected function setupInternationalization()
|
protected function setupInternationalization()
|
||||||
{
|
{
|
||||||
|
$localeDir = $this->getApplicationDir('locale');
|
||||||
|
if (file_exists($localeDir) && is_dir($localeDir)) {
|
||||||
|
Translator::registerDomain(Translator::DEFAULT_DOMAIN, $localeDir);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Translator::setupLocale(
|
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
|
: Translator::DEFAULT_LOCALE
|
||||||
);
|
);
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
Logger::error($error);
|
Logger::error($error);
|
||||||
}
|
}
|
||||||
|
|
||||||
$localeDir = $this->getApplicationDir('locale');
|
|
||||||
if (file_exists($localeDir) && is_dir($localeDir)) {
|
|
||||||
Translator::registerDomain(Translator::DEFAULT_DOMAIN, $localeDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue