diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index cabeed1d62..88d5ce1f13 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 0000000000..e7eee3bcb8 --- /dev/null +++ b/tests/data/app/description-multi-lang.xml @@ -0,0 +1,8 @@ + + + files_encryption + Server-side Encryption + English + German + AGPL + diff --git a/tests/data/app/description-single-lang.xml b/tests/data/app/description-single-lang.xml new file mode 100644 index 0000000000..5fb1ba07e8 --- /dev/null +++ b/tests/data/app/description-single-lang.xml @@ -0,0 +1,7 @@ + + + files_encryption + Server-side Encryption + English + AGPL + diff --git a/tests/lib/AppTest.php b/tests/lib/AppTest.php index 0472930384..1334aa62f1 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']); + } }