Bugfix: default language error

https://github.com/the-djmaze/snappymail/issues/1579#issuecomment-2134782450
This commit is contained in:
the-djmaze 2024-05-28 11:53:15 +02:00
parent dd39d18e2a
commit 998eb8c4bb

View file

@ -96,7 +96,7 @@ class Application extends \RainLoop\Config\AbstractConfig
{
// Workarounds for the changed application structure
if ('webmail' === $sSectionKey) {
if ('language_admin' === $sSectionKey) {
if ('language_admin' === $sParamKey) {
$sSectionKey = 'admin_panel';
$sParamKey = 'language';
}
@ -137,6 +137,16 @@ class Application extends \RainLoop\Config\AbstractConfig
$sParamKey = 'json_response_write_limit';
}
}
if ('language' === $sParamKey) {
$aLang = \SnappyMail\L10n::getLanguages('admin_panel' === $sSectionKey);
$sLanguage = \strtr($mParamValue, '_', '-');
if (!\in_array($sLanguage, $aLang)) {
if (\str_contains($sLanguage, '-')) {
$sLanguage = \strtok($sLanguage, '-');
}
}
$mParamValue = \in_array($sLanguage, $aLang) ? $sLanguage : 'en';
}
parent::Set($sSectionKey, $sParamKey, $mParamValue);
}