Skip to content

Commit

Permalink
made the %count% variable automatically available when using the tran…
Browse files Browse the repository at this point in the history
…schoice filter (similar to how the tag works)
  • Loading branch information
fabpot committed Apr 21, 2011
1 parent ea02106 commit 54b77d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
Expand Up @@ -70,7 +70,7 @@ public function trans($message, 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);
}

/**
Expand Down
Expand Up @@ -84,8 +84,8 @@ public function getTransTests()
array('{% set vars = { \'%name%\': \'Symfony2\' } %}{{ hello|trans(vars) }}', 'Hello Symfony2', array('hello' => 'Hello %name%')),

// 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('{{ 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('{{ "{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, {\'%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%)')),
);
}

Expand Down

0 comments on commit 54b77d2

Please sign in to comment.