File tree Expand file tree Collapse file tree 6 files changed +39
-6
lines changed
Expand file tree Collapse file tree 6 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 88 push :
99 branches :
1010 - " master"
11+ - " 1.x"
1112
1213jobs :
1314 phpunit :
2930 - " highest"
3031 steps :
3132 - name : " Checkout"
32- uses : " actions/checkout@v2 "
33+ uses : " actions/checkout@v4 "
3334 with :
3435 fetch-depth : 2
3536
4748 args : extra.symfony.require ${{ matrix.symfony-version }}
4849
4950 - name : " Install dependencies with Composer"
50- uses : " ramsey/composer-install@v1 "
51+ uses : " ramsey/composer-install@v3 "
5152 with :
5253 dependency-versions : " ${{ matrix.dependencies }}"
5354 composer-options : " ${{ matrix.composer-options }}"
Original file line number Diff line number Diff line change 1818
1919{{ " foo.bar4" | transchoice(5 , {' %name%' : ' Johannes' }, ' app' ) }}
2020
21- {% trans %}text.default_domain{% endtrans %}
21+ {% trans %}text.default_domain{% endtrans %}
22+
23+ {{ " foo.bar5" | trans(domain=' app' ) }}
Original file line number Diff line number Diff line change 1717{{ " foo.bar4" | trans({' %count%' : 5 , ' %name%' : ' Johannes' }, ' app' ) }}
1818
1919{% trans %}text.default_domain{% endtrans %}
20+
21+ {{ " foo.bar5" | trans(domain=' app' ) }}
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ public function testExtractSimpleTemplateInSF5()
9999 $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 19 ));
100100 $ expected ->add ($ message );
101101
102+ $ message = new Message ('foo.bar5 ' , 'app ' );
103+ $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 21 ));
104+ $ expected ->add ($ message );
105+
102106 $ this ->assertEquals ($ expected , $ this ->extract ('simple_template_sf5.html.twig ' ));
103107 }
104108
@@ -162,6 +166,10 @@ public function testExtractSimpleTemplate()
162166 $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 21 ));
163167 $ expected ->add ($ message );
164168
169+ $ message = new Message ('foo.bar5 ' , 'app ' );
170+ $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 23 ));
171+ $ expected ->add ($ message );
172+
165173 $ this ->assertEquals ($ expected , $ this ->extract ('simple_template.html.twig ' ));
166174 }
167175
Original file line number Diff line number Diff line change 2727use JMS \TranslationBundle \Translation \FileSourceFactory ;
2828use Symfony \Bridge \Twig \Node \TransNode ;
2929use Twig \Environment ;
30+ use Twig \Node \Expression \AbstractExpression ;
3031use Twig \Node \Expression \ConstantExpression ;
3132use Twig \Node \Expression \FilterExpression ;
3233use Twig \Node \Node ;
@@ -97,11 +98,11 @@ protected function doEnterNode(Node $node, Environment $env)
9798 }
9899 $ id = $ idNode ->getAttribute ('value ' );
99100
100- $ index = $ name === 'trans ' ? 1 : 2 ;
101101 $ domain = 'messages ' ;
102102 $ arguments = iterator_to_array ($ node ->getNode ('arguments ' ));
103- if (isset ($ arguments [$ index ])) {
104- $ argument = $ arguments [$ index ];
103+
104+ $ argument = $ this ->findDomainArgument ($ arguments , $ name );
105+ if (null !== $ argument ) {
105106 if (! $ argument instanceof ConstantExpression) {
106107 return $ node ;
107108
@@ -145,6 +146,20 @@ protected function doEnterNode(Node $node, Environment $env)
145146 return $ node ;
146147 }
147148
149+ private function findDomainArgument (array $ arguments , string $ name ): ?AbstractExpression
150+ {
151+ if (isset ($ arguments ['domain ' ])) {
152+ return $ arguments ['domain ' ];
153+ }
154+
155+ $ index = $ name === 'trans ' ? 1 : 2 ;
156+ if (isset ($ arguments [$ index ])) {
157+ return $ arguments [$ index ];
158+ }
159+
160+ return null ;
161+ }
162+
148163 /**
149164 * @return int
150165 */
Original file line number Diff line number Diff line change 1717 </testsuite >
1818 </testsuites >
1919
20+ <php >
21+ <env name =" SYMFONY_PHPUNIT_REQUIRE" value =" nikic/php-parser:^4.9" />
22+ <env name =" SYMFONY_PHPUNIT_VERSION" value =" 9.5" />
23+ </php >
24+
2025 <filter >
2126 <whitelist >
2227 <directory >./</directory >
You can’t perform that action at this time.
0 commit comments