made the %count% variable automatically available when using the transchoice filter (similar to how the tag works)
This commit is contained in:
parent
ea021062ba
commit
54b77d24dd
@ -70,7 +70,7 @@ class TranslationExtension extends \Twig_Extension
|
|||||||
|
|
||||||
public function transchoice($message, $count, array $arguments = array(), $domain = "messages")
|
public function transchoice($message, $count, array $arguments = array(), $domain = "messages")
|
||||||
{
|
{
|
||||||
return $this->translator->transChoice($message, $count, $arguments, $domain);
|
return $this->translator->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,8 +84,8 @@ class TranslationExtensionTest extends TestCase
|
|||||||
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')),
|
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')),
|
||||||
|
|
||||||
// transchoice filter
|
// transchoice filter
|
||||||
array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count, {\'%count%\': count}) }}', 'There is 5 apples', array('count' => 5)),
|
array('{{ "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples"|transchoice(count) }}', 'There is 5 apples', array('count' => 5)),
|
||||||
array('{{ text|transchoice(5, {\'%count%\': 5, \'%name%\': \'Symfony2\'}) }}', 'There is 5 apples (Symfony2)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')),
|
array('{{ text|transchoice(5, {\'%name%\': \'Symfony2\'}) }}', 'There is 5 apples (Symfony2)', array('text' => '{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user