From f67679ba87e4098c2268780137ec2d336e5fda6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Kr=C3=A4mer?= Date: Tue, 5 Dec 2017 13:34:09 +0100 Subject: [PATCH] Adding a test to show the issue with plurals --- .../TestCase/I18n/Parser/PoFileParserTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/TestCase/I18n/Parser/PoFileParserTest.php b/tests/TestCase/I18n/Parser/PoFileParserTest.php index e2b34797c8e..c30c1bfb248 100644 --- a/tests/TestCase/I18n/Parser/PoFileParserTest.php +++ b/tests/TestCase/I18n/Parser/PoFileParserTest.php @@ -188,4 +188,29 @@ public function testParseContextMessages() $this->assertSame('Titel mit anderem Kontext', __x('another_context', 'title')); $this->assertSame('Titel ohne Kontext', __('title')); } + + /** + * Test parsing plurals + * + * @return void + */ + public function testPlurals() + { + $parser = new PoFileParser(); + $file = APP . 'Locale' . DS . 'de' . DS . 'wa.po'; + $messages = $parser->parse($file); + + I18n::translator('default', 'de_DE', function () use ($messages) { + $package = new Package('default'); + $package->setMessages($messages); + + return $package; + }); + + // Check translated messages + I18n::locale('de_DE'); + $this->assertEquals('Standorte', __d('wa', 'Locations')); + I18n::locale('en_EN'); + $this->assertEquals('Locations', __d('wa', 'Locations')); + } }