Loading Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -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} Loading patches/032-snappy-language-fix.patch→patches/033-snappy-language-fix.patch +86 −0 Original line number Diff line number Diff line Loading @@ -4,14 +4,14 @@ 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 @@ +++ 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; Loading @@ -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,23 @@ @@ -69,8 +68,24 @@ $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; Loading @@ -31,13 +31,14 @@ This set snappy language same is cloud language + 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; + $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); Loading @@ -45,3 +46,41 @@ This set snappy language same is cloud language $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 Loading
Dockerfile +1 −1 Original line number Diff line number Diff line Loading @@ -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} Loading
patches/032-snappy-language-fix.patch→patches/033-snappy-language-fix.patch +86 −0 Original line number Diff line number Diff line Loading @@ -4,14 +4,14 @@ 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 @@ +++ 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; Loading @@ -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,23 @@ @@ -69,8 +68,24 @@ $oServiceActions = new \RainLoop\ServiceActions($oHttp, $oActions); $sAppJsMin = $oConfig->Get('debug', 'javascript', false) ? '' : '.min'; $sAppCssMin = $oConfig->Get('debug', 'css', false) ? '' : '.min'; Loading @@ -31,13 +31,14 @@ This set snappy language same is cloud language + 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; + $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); Loading @@ -45,3 +46,41 @@ This set snappy language same is cloud language $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