From 4c4d8890a073e62398961c7056a56c9c5976d345 Mon Sep 17 00:00:00 2001 From: Clemens Tolboom Date: Sat, 19 May 2012 11:54:03 +0200 Subject: [PATCH] Fixed PoFileLoader pluralhandling from interval to index. --- src/Symfony/Component/Translation/Loader/PoFileLoader.php | 2 +- .../Component/Translation/Tests/Loader/PoFileLoaderTest.php | 2 +- .../Component/Translation/Tests/MessageSelectorTest.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Translation/Loader/PoFileLoader.php b/src/Symfony/Component/Translation/Loader/PoFileLoader.php index c51b67df38..2129adcc56 100644 --- a/src/Symfony/Component/Translation/Loader/PoFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/PoFileLoader.php @@ -74,7 +74,7 @@ class PoFileLoader extends ArrayLoader implements LoaderInterface if (isset($item['ids']['plural'])) { $plurals = array(); foreach ($item['translated'] as $plural => $translated) { - $plurals[] = sprintf('{%d} %s', $plural, $translated); + $plurals[] = $translated; } $messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals)); } diff --git a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php index 1b00c60911..11c183dd54 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/PoFileLoaderTest.php @@ -39,7 +39,7 @@ class PoFileLoaderTest extends \PHPUnit_Framework_TestCase $resource = __DIR__.'/../fixtures/plurals.po'; $catalogue = $loader->load($resource, 'en', 'domain1'); - $this->assertEquals(array('foo' => 'bar', 'foos' => '{0} bar|{1} bars'), $catalogue->all('domain1')); + $this->assertEquals(array('foo' => 'bar', 'foos' => 'bar|bars'), $catalogue->all('domain1')); $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); } diff --git a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php index 5624d738f5..63ee8676d7 100644 --- a/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php +++ b/src/Symfony/Component/Translation/Tests/MessageSelectorTest.php @@ -62,6 +62,11 @@ class MessageSelectorTest extends \PHPUnit_Framework_TestCase array('', '{0}|{1} There is one apple|]1,Inf] There is %count% apples', 0), array('', '{0} There is no apples|{1}|]1,Inf] There is %count% apples', 1), + + // Indexed only tests which are Gettext PoFile* compatible strings. + array('There are %count% apples', 'There is one apple|There are %count% apples', 0), + array('There is one apple', 'There is one apple|There are %count% apples', 1), + array('There are %count% apples', 'There is one apple|There are %count% apples', 2), ); } }