[TwigBridge] added missing transchoice filters whe extracting translations from templates
This commit is contained in:
parent
789d5ad20f
commit
c73e034229
@ -59,6 +59,16 @@ class TranslationNodeVisitor implements \Twig_NodeVisitorInterface
|
||||
$node->getNode('node')->getAttribute('value'),
|
||||
$node->getNode('arguments')->hasNode(1) ? $node->getNode('arguments')->getNode(1)->getAttribute('value') : null,
|
||||
);
|
||||
} elseif (
|
||||
$node instanceof \Twig_Node_Expression_Filter &&
|
||||
'transchoice' === $node->getNode('filter')->getAttribute('value') &&
|
||||
$node->getNode('node') instanceof \Twig_Node_Expression_Constant
|
||||
) {
|
||||
// extract constant nodes with a trans filter
|
||||
$this->messages[] = array(
|
||||
$node->getNode('node')->getAttribute('value'),
|
||||
$node->getNode('arguments')->hasNode(2) ? $node->getNode('arguments')->getNode(2)->getAttribute('value') : null,
|
||||
);
|
||||
} elseif ($node instanceof TransNode) {
|
||||
// extract trans nodes
|
||||
$this->messages[] = array(
|
||||
|
@ -52,6 +52,9 @@ class TwigExtractorTest extends TestCase
|
||||
array('{{ "new key" | trans() }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | trans() | upper }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | trans({}, "domain") }}', array('new key' => 'domain')),
|
||||
array('{{ "new key" | transchoice(1) }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | transchoice(1) | upper }}', array('new key' => 'messages')),
|
||||
array('{{ "new key" | transchoice(1, {}, "domain") }}', array('new key' => 'domain')),
|
||||
array('{% trans %}new key{% endtrans %}', array('new key' => 'messages')),
|
||||
array('{% trans from "domain" %}new key{% endtrans %}', array('new key' => 'domain')),
|
||||
array('{% set foo = "new key" | trans %}', array('new key' => 'messages')),
|
||||
|
Reference in New Issue
Block a user