diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-04-17 13:45:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-17 13:45:43 +0200 |
commit | 42b7dfe9ac84da2e3e2bda732b0e94c68df9d515 (patch) | |
tree | c60a0d4c8224a908c18a76f3f90d97ecca7fb9d0 | |
parent | 1bc192fbd4ceba3aed46df77d21048baa915a176 (diff) | |
parent | 46d0d0cda14df17df3392e8233388d54e0be97dd (diff) | |
download | nextcloud-server-42b7dfe9ac84da2e3e2bda732b0e94c68df9d515.tar.gz nextcloud-server-42b7dfe9ac84da2e3e2bda732b0e94c68df9d515.zip |
Merge pull request #9159 from nextcloud/appinfo-single-localized
fix appinfo parsing when a single localized option is provided
-rw-r--r-- | lib/private/legacy/app.php | 5 | ||||
-rw-r--r-- | tests/data/app/description-multi-lang.xml | 8 | ||||
-rw-r--r-- | tests/data/app/description-single-lang.xml | 7 | ||||
-rw-r--r-- | tests/lib/AppTest.php | 14 |
4 files changed, 34 insertions, 0 deletions
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index cabeed1d62d..88d5ce1f135 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -1004,6 +1004,11 @@ class OC_App { } protected static function findBestL10NOption(array $options, string $lang): string { + // only a single option + if (isset($options['@value'])) { + return $options['@value']; + } + $fallback = $similarLangFallback = $englishFallback = false; $lang = strtolower($lang); diff --git a/tests/data/app/description-multi-lang.xml b/tests/data/app/description-multi-lang.xml new file mode 100644 index 00000000000..e7eee3bcb8b --- /dev/null +++ b/tests/data/app/description-multi-lang.xml @@ -0,0 +1,8 @@ +<?xml version="1.0"?> +<info> + <id>files_encryption</id> + <name>Server-side Encryption</name> + <description lang="en">English</description> + <description lang="de">German</description> + <licence>AGPL</licence> +</info> diff --git a/tests/data/app/description-single-lang.xml b/tests/data/app/description-single-lang.xml new file mode 100644 index 00000000000..5fb1ba07e8e --- /dev/null +++ b/tests/data/app/description-single-lang.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?> +<info> + <id>files_encryption</id> + <name>Server-side Encryption</name> + <description lang="en">English</description> + <licence>AGPL</licence> +</info> diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 04729303847..1334aa62f13 100644 --- a/tests/lib/AppTest.php +++ b/tests/lib/AppTest.php @@ -9,6 +9,7 @@ namespace Test; +use OC\App\InfoParser; use OC\AppConfig; use OCP\IAppConfig; @@ -592,5 +593,18 @@ class AppTest extends \Test\TestCase { public function testParseAppInfo(array $data, array $expected) { $this->assertSame($expected, \OC_App::parseAppInfo($data)); } + + public function testParseAppInfoL10N() { + $parser = new InfoParser(); + $data = $parser->parse(\OC::$SERVERROOT. "/tests/data/app/description-multi-lang.xml"); + $this->assertEquals('English', \OC_App::parseAppInfo($data, 'en')['description']); + $this->assertEquals('German', \OC_App::parseAppInfo($data, 'de')['description']); + } + + public function testParseAppInfoL10NSingleLanguage() { + $parser = new InfoParser(); + $data = $parser->parse(\OC::$SERVERROOT. "/tests/data/app/description-single-lang.xml"); + $this->assertEquals('English', \OC_App::parseAppInfo($data, 'en')['description']); + } } |