]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(l10n): Respect forceLanguage query parameter in more places feat/add-query-param-to-force-language 48613/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 8 Oct 2024 13:40:40 +0000 (15:40 +0200)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Tue, 8 Oct 2024 13:40:40 +0000 (15:40 +0200)
Attempt to make L10N Factory consistent with itself when forceLanguage
 query parameter is used.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
lib/private/L10N/Factory.php

index dc65714c11bf0bc9cde2debd5e4478242ac71e9c..eb84f264f5fc8f1f6b4ee72b4dc7e1f3576396b1 100644 (file)
@@ -139,7 +139,7 @@ class Factory implements IFactory {
         */
        public function findLanguage(?string $appId = null): string {
                // Step 1: Forced language always has precedence over anything else
-               $forceLang = $this->config->getSystemValue('force_language', false);
+               $forceLang = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
                if (is_string($forceLang)) {
                        $this->requestLanguage = $forceLang;
                }
@@ -196,7 +196,7 @@ class Factory implements IFactory {
 
        public function findGenericLanguage(?string $appId = null): string {
                // Step 1: Forced language always has precedence over anything else
-               $forcedLanguage = $this->config->getSystemValue('force_language', false);
+               $forcedLanguage = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
                if ($forcedLanguage !== false) {
                        return $forcedLanguage;
                }
@@ -411,6 +411,10 @@ class Factory implements IFactory {
                                return $language;
                        }
 
+                       if (($forcedLanguage = $this->request->getParam('forceLanguage')) !== null) {
+                               return $forcedLanguage;
+                       }
+
                        // Use language from request
                        if ($this->userSession->getUser() instanceof IUser &&
                                $user->getUID() === $this->userSession->getUser()->getUID()) {
@@ -421,7 +425,7 @@ class Factory implements IFactory {
                        }
                }
 
-               return $this->config->getSystemValueString('default_language', 'en');
+               return $this->request->getParam('forceLanguage') ?? $this->config->getSystemValueString('default_language', 'en');
        }
 
        /**