aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2024-10-08 16:29:03 +0200
committerGitHub <noreply@github.com>2024-10-08 16:29:03 +0200
commitf8c987f02952b83b235c705cf5df7f7f8a37ea47 (patch)
tree707896ef1f2375ad1d6ddda73a3146be684af840 /lib
parent614d8c23a0d628ef3d39b28c760f0988c80ad5a9 (diff)
parent5a05af05db89c1698892c640ccb6852019d432ee (diff)
downloadnextcloud-server-f8c987f02952b83b235c705cf5df7f7f8a37ea47.tar.gz
nextcloud-server-f8c987f02952b83b235c705cf5df7f7f8a37ea47.zip
Merge pull request #48613 from nextcloud/feat/add-query-param-to-force-language
feat(l10n): Allow to force language with a query parameter
Diffstat (limited to 'lib')
-rw-r--r--lib/private/L10N/Factory.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index ecf7381ba99..eb84f264f5f 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -98,7 +98,7 @@ class Factory implements IFactory {
$lang = str_replace(['\0', '/', '\\', '..'], '', $lang);
}
- $forceLang = $this->config->getSystemValue('force_language', false);
+ $forceLang = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
if (is_string($forceLang)) {
$lang = $forceLang;
}
@@ -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');
}
/**