Fixed PoFileLoader pluralhandling from interval to index.
This commit is contained in:
parent
58b924533a
commit
4c4d8890a0
@ -74,7 +74,7 @@ class PoFileLoader extends ArrayLoader implements LoaderInterface
|
|||||||
if (isset($item['ids']['plural'])) {
|
if (isset($item['ids']['plural'])) {
|
||||||
$plurals = array();
|
$plurals = array();
|
||||||
foreach ($item['translated'] as $plural => $translated) {
|
foreach ($item['translated'] as $plural => $translated) {
|
||||||
$plurals[] = sprintf('{%d} %s', $plural, $translated);
|
$plurals[] = $translated;
|
||||||
}
|
}
|
||||||
$messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals));
|
$messages[$item['ids']['plural']] = stripcslashes(implode('|', $plurals));
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class PoFileLoaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$resource = __DIR__.'/../fixtures/plurals.po';
|
$resource = __DIR__.'/../fixtures/plurals.po';
|
||||||
$catalogue = $loader->load($resource, 'en', 'domain1');
|
$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('en', $catalogue->getLocale());
|
||||||
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
$this->assertEquals(array(new FileResource($resource)), $catalogue->getResources());
|
||||||
}
|
}
|
||||||
|
@ -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}|{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),
|
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),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user