From 5a05af05db89c1698892c640ccb6852019d432ee Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Tue, 8 Oct 2024 15:40:40 +0200 Subject: [PATCH] feat(l10n): Respect forceLanguage query parameter in more places MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Attempt to make L10N Factory consistent with itself when forceLanguage query parameter is used. Signed-off-by: Côme Chilliet --- lib/private/L10N/Factory.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php index dc65714c11b..eb84f264f5f 100644 --- a/lib/private/L10N/Factory.php +++ b/lib/private/L10N/Factory.php @@ -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'); } /** -- 2.39.5