8000 [Translation] Extract translatable content on twig set · symfony/symfony@ab9ad6b · GitHub
[go: up one dir, main page]

Skip to content

Commit ab9ad6b

Browse files
natewiebe13fabpot
authored andcommitted
[Translation] Extract translatable content on twig set
1 parent 803a998 commit ab9ad6b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,10 @@ protected function doEnterNode(Node $node, Environment $env): Node
6969
$this->getReadDomainFromArguments($node->getNode('arguments'), 1),
7070
];
7171
} elseif (
72-
$node instanceof FilterExpression &&
73-
'trans' === $node->getNode('filter')->getAttribute('value') &&
74-
$node->getNode('node') instanceof FunctionExpression &&
75-
't' === $node->getNode('node')->getAttribute('name')
72+
$node instanceof FunctionExpression &&
73+
't' === $node->getAttribute('name')
7674
) {
77-
$nodeArguments = $node->getNode('node')->getNode('arguments');
75+
$nodeArguments = $node->getNode('arguments');
7876

7977
if ($nodeArguments->getIterator()->current() instanceof ConstantExpression) {
8078
$this->messages[] = [

src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function getExtractData()
6666
['{% set foo = "new key" | trans %}', ['new key' => 'messages']],
6767
['{{ 1 ? "new key" | trans : "another key" | trans }}', ['new key' => 'messages', 'another key' => 'messages']],
6868
['{{ t("new key") | trans() }}', ['new key' => 'messages']],
69+
['{% set foo = t("new key") %}', ['new key' => 'messages']],
6970
['{{ t("new key", {}, "domain") | trans() }}', ['new key' => 'domain']],
7071
['{{ 1 ? t("new key") | trans : t("another key") | trans }}', ['new key' => 'messages', 'another key' => 'messages']],
7172

0 commit comments

Comments
 (0)
0