From ab9ad6bd3b34887cff0d249cf6db15b7880adf93 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Fri, 16 Jul 2021 15:11:41 -0400 Subject: [PATCH] [Translation] Extract translatable content on twig set --- .../Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php | 8 +++----- .../Bridge/Twig/Tests/Translation/TwigExtractorTest.php | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php index e5b0fc4ea1b73..d42245e2b89a4 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/TranslationNodeVisitor.php @@ -69,12 +69,10 @@ protected function doEnterNode(Node $node, Environment $env): Node $this->getReadDomainFromArguments($node->getNode('arguments'), 1), ]; } elseif ( - $node instanceof FilterExpression && - 'trans' === $node->getNode('filter')->getAttribute('value') && - $node->getNode('node') instanceof FunctionExpression && - 't' === $node->getNode('node')->getAttribute('name') + $node instanceof FunctionExpression && + 't' === $node->getAttribute('name') ) { - $nodeArguments = $node->getNode('node')->getNode('arguments'); + $nodeArguments = $node->getNode('arguments'); if ($nodeArguments->getIterator()->current() instanceof ConstantExpression) { $this->messages[] = [ diff --git a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php index 6a7336d7b1995..8013714d7b40c 100644 --- a/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php @@ -66,6 +66,7 @@ public function getExtractData() ['{% set foo = "new key" | trans %}', ['new key' => 'messages']], ['{{ 1 ? "new key" | trans : "another key" | trans }}', ['new key' => 'messages', 'another key' => 'messages']], ['{{ t("new key") | trans() }}', ['new key' => 'messages']], + ['{% set foo = t("new key") %}', ['new key' => 'messages']], ['{{ t("new key", {}, "domain") | trans() }}', ['new key' => 'domain']], ['{{ 1 ? t("new key") | trans : t("another key") | trans }}', ['new key' => 'messages', 'another key' => 'messages']], pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy