From f1c37183ec409547b5c03b1bf8f6c990e632e343 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 27 Nov 2023 13:31:38 +0530 Subject: [PATCH 1/8] webmail lang fix --- patches/032-snappy-language-fix.patch | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 patches/032-snappy-language-fix.patch diff --git a/patches/032-snappy-language-fix.patch b/patches/032-snappy-language-fix.patch new file mode 100644 index 00000000..d7e98119 --- /dev/null +++ b/patches/032-snappy-language-fix.patch @@ -0,0 +1,17 @@ +From: Avinash Gusain +Date: Mon, 27 Nov 2023 13:40:00 +0530 +Subject: [PATCH] Snappy Language fix + +This set snappy language same is cloud language +--- ./custom_apps/snappymail/lib/ControllerPageController.php 2023-11-27 12:15:41 ++++ ./custom_apps/snappymail/lib/ControllerPageController-new.php 2023-11-27 12:36:00 +@@ -54,7 +54,8 @@ + $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); + $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; + $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; +- $sLanguage = $oActions->GetLanguage(false); ++ $userId = \OC::$server->getUserSession()->getUser()->getUID(); ++ $sLanguage = $this->config->getUserValue($userId, 'core', 'lang', null); + + $csp = new ContentSecurityPolicy(); + $sNonce = $csp->getSnappyMailNonce(); -- GitLab From 0cba0b2c7adb32f1f559dbfe58c59212003a2155 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 27 Nov 2023 13:54:40 +0530 Subject: [PATCH 2/8] webmail lang fix --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b30d6601..0813fe5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ ARG SNAPPY_THEME_VERSION="3.0.0" ARG USER_MIGRATION_JOB_ID="608716" ARG MEMORIES_VERSION="5.4.1" -RUN sed -i 's/26,0,8,2/26,0,8,12/' ${BASE_DIR}/version.php +RUN sed -i 's/26,0,8,2/26,0,8,13/' ${BASE_DIR}/version.php COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images @@ -144,6 +144,7 @@ RUN patch -u ${BASE_DIR}/apps/dav/lib/CalDAV/Reminder/ReminderService.php -i ${T RUN patch -u ${BASE_DIR}/apps/theming/lib/Themes/CommonThemeTrait.php -i ${TMP_PATCH_DIR}/026-primary-color-fix.patch RUN patch -u ${BASE_DIR}/lib/private/Preview/Watcher.php -i ${TMP_PATCH_DIR}/030-preview-watcher-null-check.patch RUN patch -u ${BASE_DIR}/lib/private/Template/JSResourceLocator.php -i ${TMP_PATCH_DIR}/031-theme-custom-app-translations.patch +RUN patch -u ${BASE_DIR}/custom_apps/snappymail/lib/ControllerPageController.php -i ${TMP_PATCH_DIR}/032-snappy-language-fix.patch RUN rm -rf ${TMP_PATCH_DIR} -- GitLab From 39f42a2cd07b290c92638319603eb9224b046566 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 27 Nov 2023 14:03:34 +0530 Subject: [PATCH 3/8] webmail lang fix --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0813fe5a..9f1a84e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -144,7 +144,7 @@ RUN patch -u ${BASE_DIR}/apps/dav/lib/CalDAV/Reminder/ReminderService.php -i ${T RUN patch -u ${BASE_DIR}/apps/theming/lib/Themes/CommonThemeTrait.php -i ${TMP_PATCH_DIR}/026-primary-color-fix.patch RUN patch -u ${BASE_DIR}/lib/private/Preview/Watcher.php -i ${TMP_PATCH_DIR}/030-preview-watcher-null-check.patch RUN patch -u ${BASE_DIR}/lib/private/Template/JSResourceLocator.php -i ${TMP_PATCH_DIR}/031-theme-custom-app-translations.patch -RUN patch -u ${BASE_DIR}/custom_apps/snappymail/lib/ControllerPageController.php -i ${TMP_PATCH_DIR}/032-snappy-language-fix.patch +RUN patch -u ${BASE_DIR}/custom_apps/snappymail/lib/Controller/PageController.php -i ${TMP_PATCH_DIR}/032-snappy-language-fix.patch RUN rm -rf ${TMP_PATCH_DIR} -- GitLab From fdf7810abbaeb791f947a97ced5f4e63b394040c Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Mon, 27 Nov 2023 14:28:45 +0530 Subject: [PATCH 4/8] webmail lang fix --- patches/032-snappy-language-fix.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/032-snappy-language-fix.patch b/patches/032-snappy-language-fix.patch index d7e98119..92b0eb14 100644 --- a/patches/032-snappy-language-fix.patch +++ b/patches/032-snappy-language-fix.patch @@ -3,8 +3,8 @@ Date: Mon, 27 Nov 2023 13:40:00 +0530 Subject: [PATCH] Snappy Language fix This set snappy language same is cloud language ---- ./custom_apps/snappymail/lib/ControllerPageController.php 2023-11-27 12:15:41 -+++ ./custom_apps/snappymail/lib/ControllerPageController-new.php 2023-11-27 12:36:00 +--- ./custom_apps/snappymail/lib/Controller/PageController.php 2023-11-27 12:15:41 ++++ ./custom_apps/snappymail/lib/Controller/PageController-new.php 2023-11-27 12:36:00 @@ -54,7 +54,8 @@ $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; -- GitLab From c1c58987adfff048e76e1a752e62d958845c78da Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 29 Nov 2023 00:49:04 +0530 Subject: [PATCH 5/8] snappymail lang fix --- Dockerfile | 2 +- patches/032-snappy-language-fix.patch | 40 +++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9f1a84e5..4b1c29b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ARG EA_JOB_ID="738865" ARG LAUNCHER_JOB_ID="738816" ARG GOOGLE_INTEGRATION_VERSION="2.1.0" ARG DASHBOARD_JOB_ID="748055" -ARG SNAPPY_VERSION="2.29.1" +ARG SNAPPY_VERSION="2.29.4" ARG SNAPPY_THEME_VERSION="3.0.0" ARG USER_MIGRATION_JOB_ID="608716" ARG MEMORIES_VERSION="5.4.1" diff --git a/patches/032-snappy-language-fix.patch b/patches/032-snappy-language-fix.patch index 92b0eb14..6824321e 100644 --- a/patches/032-snappy-language-fix.patch +++ b/patches/032-snappy-language-fix.patch @@ -3,15 +3,43 @@ Date: Mon, 27 Nov 2023 13:40:00 +0530 Subject: [PATCH] Snappy Language fix This set snappy language same is cloud language ---- ./custom_apps/snappymail/lib/Controller/PageController.php 2023-11-27 12:15:41 -+++ ./custom_apps/snappymail/lib/Controller/PageController-new.php 2023-11-27 12:36:00 -@@ -54,7 +54,8 @@ +--- PageController.php 2023-11-29 00:29:13 ++++ PageController-new.php 2023-11-29 00:40:50 +@@ -12,11 +12,11 @@ + + class PageController extends Controller + { +-// private IL10N $l; ++ private IL10N $l; + + public function __construct(string $appName, IRequest $request, IL10N $l) { + parent::__construct($appName, $request); +-// $this->l = $l; ++ $this->l = $l; + $lang = \strtolower(\str_replace('_', '-', $l->getLocaleCode())); + if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; +@@ -69,8 +69,20 @@ $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; - $sLanguage = $oActions->GetLanguage(false); -+ $userId = \OC::$server->getUserSession()->getUser()->getUID(); -+ $sLanguage = $this->config->getUserValue($userId, 'core', 'lang', null); - +- ++ $languageSetting = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); ++ if (!$languageSetting) { ++ $aResultLang = \json_decode(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/localization/langs.json'), true); ++ $localeCode = \strtolower(\str_replace('_', '-', $this->l->getLocaleCode())); ++ if (!strpos($localeCode, '_') && !strpos($localeCode, '-')) { ++ $localeCode = $localeCode . '-' . strtoupper($localeCode); ++ } ++ $sLanguage = 'en'; ++ if(isset($aResultLang['LANGS_NAMES_EN'][$localeCode])) { ++ $sLanguage = $localeCode; ++ } ++ }else { ++ $sLanguage = $oActions->GetLanguage(false); ++ } $csp = new ContentSecurityPolicy(); $sNonce = $csp->getSnappyMailNonce(); + + -- GitLab From 240141c74a1c4c10e3897cbc4e6f4cfcd3844e45 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Wed, 6 Dec 2023 10:46:14 +0530 Subject: [PATCH 6/8] added exception check --- patches/032-snappy-language-fix.patch | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/patches/032-snappy-language-fix.patch b/patches/032-snappy-language-fix.patch index 6824321e..64fb5e60 100644 --- a/patches/032-snappy-language-fix.patch +++ b/patches/032-snappy-language-fix.patch @@ -4,7 +4,7 @@ Subject: [PATCH] Snappy Language fix This set snappy language same is cloud language --- PageController.php 2023-11-29 00:29:13 -+++ PageController-new.php 2023-11-29 00:40:50 ++++ PageController-new.php 2023-12-06 10:37:52 @@ -12,11 +12,11 @@ class PageController extends Controller @@ -19,7 +19,7 @@ This set snappy language same is cloud language $lang = \strtolower(\str_replace('_', '-', $l->getLocaleCode())); if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; -@@ -69,8 +69,20 @@ +@@ -69,8 +69,23 @@ $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; @@ -28,6 +28,9 @@ This set snappy language same is cloud language + $languageSetting = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); + if (!$languageSetting) { + $aResultLang = \json_decode(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/localization/langs.json'), true); ++ if ($aResultLang === null) { ++ throw new \Exception('Error decoding JSON content.'); ++ } + $localeCode = \strtolower(\str_replace('_', '-', $this->l->getLocaleCode())); + if (!strpos($localeCode, '_') && !strpos($localeCode, '-')) { + $localeCode = $localeCode . '-' . strtoupper($localeCode); @@ -42,4 +45,3 @@ This set snappy language same is cloud language $csp = new ContentSecurityPolicy(); $sNonce = $csp->getSnappyMailNonce(); - -- GitLab From 910be5a4dfec95fbecb33599f18e280d438333df Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Fri, 8 Dec 2023 21:31:12 +0530 Subject: [PATCH 7/8] language fix --- Dockerfile | 2 +- patches/032-snappy-language-fix.patch | 47 --------------- patches/033-snappy-language-fix.patch | 86 +++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 48 deletions(-) delete mode 100644 patches/032-snappy-language-fix.patch create mode 100644 patches/033-snappy-language-fix.patch diff --git a/Dockerfile b/Dockerfile index 4b1c29b4..f6657438 100644 --- a/Dockerfile +++ b/Dockerfile @@ -144,7 +144,7 @@ RUN patch -u ${BASE_DIR}/apps/dav/lib/CalDAV/Reminder/ReminderService.php -i ${T RUN patch -u ${BASE_DIR}/apps/theming/lib/Themes/CommonThemeTrait.php -i ${TMP_PATCH_DIR}/026-primary-color-fix.patch RUN patch -u ${BASE_DIR}/lib/private/Preview/Watcher.php -i ${TMP_PATCH_DIR}/030-preview-watcher-null-check.patch RUN patch -u ${BASE_DIR}/lib/private/Template/JSResourceLocator.php -i ${TMP_PATCH_DIR}/031-theme-custom-app-translations.patch -RUN patch -u ${BASE_DIR}/custom_apps/snappymail/lib/Controller/PageController.php -i ${TMP_PATCH_DIR}/032-snappy-language-fix.patch +RUN patch -u ${BASE_DIR}/custom_apps/snappymail/lib/Controller/PageController.php -i ${TMP_PATCH_DIR}/033-snappy-language-fix.patch RUN rm -rf ${TMP_PATCH_DIR} diff --git a/patches/032-snappy-language-fix.patch b/patches/032-snappy-language-fix.patch deleted file mode 100644 index 64fb5e60..00000000 --- a/patches/032-snappy-language-fix.patch +++ /dev/null @@ -1,47 +0,0 @@ -From: Avinash Gusain -Date: Mon, 27 Nov 2023 13:40:00 +0530 -Subject: [PATCH] Snappy Language fix - -This set snappy language same is cloud language ---- PageController.php 2023-11-29 00:29:13 -+++ PageController-new.php 2023-12-06 10:37:52 -@@ -12,11 +12,11 @@ - - class PageController extends Controller - { --// private IL10N $l; -+ private IL10N $l; - - public function __construct(string $appName, IRequest $request, IL10N $l) { - parent::__construct($appName, $request); --// $this->l = $l; -+ $this->l = $l; - $lang = \strtolower(\str_replace('_', '-', $l->getLocaleCode())); - if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; -@@ -69,8 +69,23 @@ - $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); - $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; - $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; -- $sLanguage = $oActions->GetLanguage(false); -- -+ $languageSetting = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); -+ if (!$languageSetting) { -+ $aResultLang = \json_decode(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/localization/langs.json'), true); -+ if ($aResultLang === null) { -+ throw new \Exception('Error decoding JSON content.'); -+ } -+ $localeCode = \strtolower(\str_replace('_', '-', $this->l->getLocaleCode())); -+ if (!strpos($localeCode, '_') && !strpos($localeCode, '-')) { -+ $localeCode = $localeCode . '-' . strtoupper($localeCode); -+ } -+ $sLanguage = 'en'; -+ if(isset($aResultLang['LANGS_NAMES_EN'][$localeCode])) { -+ $sLanguage = $localeCode; -+ } -+ }else { -+ $sLanguage = $oActions->GetLanguage(false); -+ } - $csp = new ContentSecurityPolicy(); - $sNonce = $csp->getSnappyMailNonce(); - diff --git a/patches/033-snappy-language-fix.patch b/patches/033-snappy-language-fix.patch new file mode 100644 index 00000000..4ca153da --- /dev/null +++ b/patches/033-snappy-language-fix.patch @@ -0,0 +1,86 @@ +From: Avinash Gusain +Date: Mon, 27 Nov 2023 13:40:00 +0530 +Subject: [PATCH] Snappy Language fix + +This set snappy language same is cloud language +--- PageController.php 2023-11-29 00:29:13 ++++ PageController-new.php 2023-12-08 20:27:04 +@@ -12,11 +12,10 @@ + + class PageController extends Controller + { +-// private IL10N $l; +- ++ private IL10N $l; + public function __construct(string $appName, IRequest $request, IL10N $l) { + parent::__construct($appName, $request); +-// $this->l = $l; ++ $this->l = $l; + $lang = \strtolower(\str_replace('_', '-', $l->getLocaleCode())); + if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $lang; +@@ -69,8 +68,24 @@ + $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); + $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; + $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; +- $sLanguage = $oActions->GetLanguage(false); +- ++ $languageSetting = (bool) $oConfig->Get('webmail', 'allow_languages_on_settings', true); ++ if (!$languageSetting) { ++ $aResultLang = \json_decode(\file_get_contents(APP_VERSION_ROOT_PATH . 'app/localization/langs.json'), true); ++ if ($aResultLang === null) { ++ throw new \Exception('Error decoding JSON content.'); ++ } ++ $user = \OC::$server->getUserSession()->getUser(); ++ $userId = $user->getUID(); ++ $langCode = $config->getUserValue($userId, 'core', 'lang'); ++ $userLang = \OC::$server->getConfig()->getUserValue($userId, 'core', 'lang'); ++ $sLanguage = $this->determineLocale($langCode,$aResultLang['LANGS_NAMES_EN']); ++ // Check if $sLanguage is null ++ if ($sLanguage === null) { ++ $sLanguage = 'en'; // Assign 'en' if $sLanguage is null ++ } ++ }else { ++ $sLanguage = $oActions->GetLanguage(false); ++ } + $csp = new ContentSecurityPolicy(); + $sNonce = $csp->getSnappyMailNonce(); + +@@ -129,4 +144,36 @@ + { + return SnappyMailHelper::startApp(true); + } ++ /** ++ * Determine locale from user language. ++ * ++ * @param string $langCode The name of the input. ++ * @param array $languagesArray The value of the array. ++ * ++ * @return string return locale ++ */ ++ ++ private function determineLocale (string $langCode, array $languagesArray) : string { ++ // Direct check for the language code ++ if (isset($languagesArray[$langCode])) { ++ return $langCode; ++ } ++ ++ // Check with uppercase country code ++ $langCodeWithUpperCase = $langCode . '-' . strtoupper($langCode); ++ if (isset($languagesArray[$langCodeWithUpperCase])) { ++ return $langCodeWithUpperCase; ++ } ++ ++ // Iterating to find a match starting with langCode ++ foreach ($languagesArray as $localeKey => $localeValue) { ++ if (strpos($localeKey, $langCode) === 0) { ++ return $localeKey; ++ } ++ } ++ ++ // If no match is found ++ return null; ++ } ++ + } +\ No newline at end of file -- GitLab From 3b6f9fddae21437ba3c19d1cb5068ab76227157d Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Fri, 8 Dec 2023 21:36:55 +0530 Subject: [PATCH 8/8] lang fx --- patches/033-snappy-language-fix.patch | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/033-snappy-language-fix.patch b/patches/033-snappy-language-fix.patch index 4ca153da..51c78de2 100644 --- a/patches/033-snappy-language-fix.patch +++ b/patches/033-snappy-language-fix.patch @@ -83,4 +83,3 @@ This set snappy language same is cloud language + } + } -\ No newline at end of file -- GitLab