Forráskód Böngészése

[Bridge][Twig] removed the possibility to pass a message to the transchoice tag

Martin Hason 14 éve
szülő
commit
b7c417feaa

+ 4 - 13
src/Symfony/Bridge/Twig/TokenParser/TransChoiceTokenParser.php

@@ -34,16 +34,9 @@ class TransChoiceTokenParser extends TransTokenParser
 
         $vars = new \Twig_Node_Expression_Array(array(), $lineno);
 
-        $body = null;
         $count = $this->parser->getExpressionParser()->parseExpression();
-        $domain = new \Twig_Node_Expression_Constant('messages', $lineno);
 
-        if (!$stream->test(\Twig_Token::BLOCK_END_TYPE) && $stream->test('for')) {
-            // {% transchoice count for "message" %}
-            // {% transchoice count for message %}
-            $stream->next();
-            $body = $this->parser->getExpressionParser()->parseExpression();
-        }
+        $domain = new \Twig_Node_Expression_Constant('messages', $lineno);
 
         if ($stream->test('with')) {
             // {% transchoice count with vars %}
@@ -57,11 +50,9 @@ class TransChoiceTokenParser extends TransTokenParser
             $domain = $this->parser->getExpressionParser()->parseExpression();
         }
 
-        if (null === $body) {
-            // {% transchoice count %}message{% endtranschoice %}
-            $stream->expect(\Twig_Token::BLOCK_END_TYPE);
-            $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
-        }
+        $stream->expect(\Twig_Token::BLOCK_END_TYPE);
+
+        $body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);
 
         if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
             throw new \Twig_Error_Syntax('A message must be a simple text.');

+ 0 - 4
tests/Symfony/Tests/Bridge/Twig/Extension/TranslationExtensionTest.php

@@ -65,10 +65,6 @@ class TranslationExtensionTest extends TestCase
                 'There is 5 apples (Symfony2)', array('count' => 5, 'name' => 'Symfony2')),
             array('{% transchoice count with { \'%name%\': \'Symfony2\' } %}{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%){% endtranschoice %}',
                 'There is 5 apples (Symfony2)', array('count' => 5)),
-            array('{% transchoice count for "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples" from "messages" %}',
-                'There is one apple', array('count' => 1)),
-            array('{% set text = "{0} There is no apples|{1} There is one apple|]1,Inf] There is %count% apples (%name%)" %}{% transchoice count for text with { \'%name%\': \'Symfony2\', \'%count%\': count } %}',
-                'There is 5 apples (Symfony2)', array('count' => 5)),
 
             // trans filter
             array('{{ "Hello"|trans }}', 'Hello'),