Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit67d8a59

Browse files
committed
bug#42160 [Translation] Extract translatable content on twig set (natewiebe13)
This PR was submitted for the 5.2 branch but it was squashed and merged into the 5.3 branch instead.Discussion----------[Translation] Extract translatable content on twig set| Q | A| ------------- | ---| Branch? | 5.2| Bug fix? | yes| New feature? | no| Deprecations? | no| License | MITWhen extracting messages from Twig templates, the extractor was only considering the `t()` function when it was being immediately filtered by the `trans` filter. Instead it should be happening when the message object is created.Commits-------ab9ad6b [Translation] Extract translatable content on twig set
2 parents803a998 +ab9ad6b commit67d8a59

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-
$nodeinstanceof FilterExpression &&
73-
'trans' ===$node->getNode('filter')->getAttribute('value') &&
74-
$node->getNode('node')instanceof FunctionExpression &&
75-
't' ===$node->getNode('node')->getAttribute('name')
72+
$nodeinstanceof 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)

[8]ページ先頭

©2009-2025 Movatter.jp