diff options
author | Joas Schilling <coding@schilljs.com> | 2023-06-21 07:11:16 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-06-27 14:13:00 +0200 |
commit | 81f9d9a690ee540e640865d9e21f53ae8c37c6bf (patch) | |
tree | 67323298963ef91a52ea42dd10bd57d6da962470 /tests | |
parent | ff04de6fbcf21d57410305a6e123d0d2f30491f7 (diff) | |
download | nextcloud-server-81f9d9a690ee540e640865d9e21f53ae8c37c6bf.tar.gz nextcloud-server-81f9d9a690ee540e640865d9e21f53ae8c37c6bf.zip |
fix(l10n): Fix plural issue with different locale and language
We need to use the language code here instead of the locale,
because Symfony does not distinguish between the two and would
otherwise e.g. with locale "Czech" and language "German" try to
pick a non-existing plural rule, because Czech has 4 plural forms
and German only 2.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/L10N/L10nTest.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index f224592432c..67ad5843546 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/tests/lib/L10N/L10nTest.php @@ -85,6 +85,15 @@ class L10nTest extends TestCase { $this->assertEquals('5 oken', (string)$l->n('%n window', '%n windows', 5)); } + public function testGermanPluralWithCzechLocaleTranslations() { + $transFile = \OC::$SERVERROOT.'/tests/data/l10n/de.json'; + $l = new L10N($this->getFactory(), 'test', 'de', 'cs_CZ', [$transFile]); + + $this->assertEquals('1 Datei', (string) $l->n('%n file', '%n files', 1)); + $this->assertEquals('2 Dateien', (string) $l->n('%n file', '%n files', 2)); + $this->assertEquals('5 Dateien', (string) $l->n('%n file', '%n files', 5)); + } + public function dataPlaceholders(): array { return [ ['Ordered placeholders one %s two %s', 'Placeholder one 1 two 2'], |