Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 240141c7 authored by AVINASH GUSAIN's avatar AVINASH GUSAIN
Browse files

added exception check

parent c1c58987
Loading
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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();