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

Unverified Commit d7306595 authored by Akhil's avatar Akhil
Browse files

Use $_SERVER for language

parent 3080003e
Loading
Loading
Loading
Loading
+10 −4
Original line number Diff line number Diff line
@@ -2,13 +2,19 @@ From: Akhil <akhil.potukuchi.ext@murena.com>
Date: Fri, 29 Nov 2023 17:50:00 +0530
Subject: [PATCH] Check session to select language

As we are unable to change the ACCEPT_LANGUAGE header for a public page, findLanguage always returns 'en'. To use this, do \OC::$server->getSession()->set('selected_language', $lang);
$_SERVER in IRequest is immutable but we want to switch the header to deliver translation files correctly

--- lib/private/L10N/Factory.php	2023-11-29 17:46:48.253716340 +0530
+++ lib/private/L10N/Factory-new.php	2023-11-29 17:47:26.194920628 +0530
@@ -213,6 +213,11 @@
 			}
 		}
@@ -478,7 +478,8 @@
 	 * @throws LanguageNotFoundException
 	 */
 	private function getLanguageFromRequest(?string $app = null): string {
-		$header = $this->request->getHeader('ACCEPT_LANGUAGE');
+		// $header = $this->request->getHeader('ACCEPT_LANGUAGE');
+		$header = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
 		if ($header !== '') {
 			$available = $this->findAvailableLanguages($app);
 
+		$selectedLang = \OC::$server->getSession()->get('selected_language');
+		if (!empty($selectedLang) && $this->languageExists($appId, $selectedLang)) {