Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2018-05-09 13:05:46 +0300
committerGeorg Ehrke <developer@georgehrke.com>2018-05-24 14:09:15 +0300
commit0dc1b3e741caa3a160aff9c2680e5db024d54a71 (patch)
treeeea70dc6790a539057e26a749f0dc3ea18e4403a
parentb9584e1b2519f752d33ffae7aea7e32023977c35 (diff)
make sure force language is reflected in html lang attribute
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
-rw-r--r--lib/private/L10N/Factory.php6
-rw-r--r--tests/lib/L10N/FactoryTest.php50
2 files changed, 49 insertions, 7 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index 399bebb8189..658a8793c69 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -130,6 +130,12 @@ class Factory implements IFactory {
return $this->requestLanguage;
}
+ $forceLang = $this->config->getSystemValue('force_language', false);
+ if (is_string($forceLang) && $this->languageExists($app, $forceLang)) {
+ $this->requestLanguage = $forceLang;
+ return $forceLang;
+ }
+
/**
* At this point Nextcloud might not yet be installed and thus the lookup
* in the preferences table might fail. For this reason we need to check
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index 77a56b5f945..934dfe08e43 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -110,7 +110,12 @@ class FactoryTest extends TestCase {
->with('MyApp', 'de')
->willReturn(false);
$this->config
- ->expects($this->once())
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('force_language', false)
+ ->willReturn(false);
+ $this->config
+ ->expects($this->at(1))
->method('getSystemValue')
->with('installed', false)
->willReturn(true);
@@ -144,7 +149,12 @@ class FactoryTest extends TestCase {
->with('MyApp', 'de')
->willReturn(false);
$this->config
- ->expects($this->at(0))
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('force_language', false)
+ ->willReturn(false);
+ $this->config
+ ->expects($this->at(1))
->method('getSystemValue')
->with('installed', false)
->willReturn(true);
@@ -167,7 +177,7 @@ class FactoryTest extends TestCase {
->with('MyApp', 'jp')
->willReturn(false);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('getSystemValue')
->with('default_language', false)
->willReturn('es');
@@ -187,7 +197,12 @@ class FactoryTest extends TestCase {
->with('MyApp', 'de')
->willReturn(false);
$this->config
- ->expects($this->at(0))
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('force_language', false)
+ ->willReturn(false);
+ $this->config
+ ->expects($this->at(1))
->method('getSystemValue')
->with('installed', false)
->willReturn(true);
@@ -210,7 +225,7 @@ class FactoryTest extends TestCase {
->with('MyApp', 'jp')
->willReturn(false);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('getSystemValue')
->with('default_language', false)
->willReturn('es');
@@ -233,7 +248,12 @@ class FactoryTest extends TestCase {
->with('MyApp', 'de')
->willReturn(false);
$this->config
- ->expects($this->at(0))
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('force_language', false)
+ ->willReturn(false);
+ $this->config
+ ->expects($this->at(1))
->method('getSystemValue')
->with('installed', false)
->willReturn(true);
@@ -256,7 +276,7 @@ class FactoryTest extends TestCase {
->with('MyApp', 'jp')
->willReturn(false);
$this->config
- ->expects($this->at(2))
+ ->expects($this->at(3))
->method('getSystemValue')
->with('default_language', false)
->willReturn('es');
@@ -273,6 +293,22 @@ class FactoryTest extends TestCase {
$this->assertSame('en', $factory->findLanguage('MyApp'));
}
+ public function testFindLanguageWithForcedLanguage() {
+ $factory = $this->getFactory(['languageExists']);
+ $this->config
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('force_language', false)
+ ->willReturn('de');
+
+ $factory->expects($this->once())
+ ->method('languageExists')
+ ->with('MyApp', 'de')
+ ->willReturn(true);
+
+ $this->assertSame('de', $factory->findLanguage('MyApp'));
+ }
+
/**
* @dataProvider dataFindAvailableLanguages
*