From 998eb8c4bbbc4122198dd67f7ee2e0a1021a5a7c Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 28 May 2024 11:53:15 +0200 Subject: [PATCH] Bugfix: default language error https://github.com/the-djmaze/snappymail/issues/1579#issuecomment-2134782450 --- .../app/libraries/RainLoop/Config/Application.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index aa479feaa..1d2c6489f 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -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); }