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 8
8
push :
9
9
branches :
10
10
- " master"
11
+ - " 1.x"
11
12
12
13
jobs :
13
14
phpunit :
29
30
- " highest"
30
31
steps :
31
32
- name : " Checkout"
32
- uses : " actions/checkout@v2 "
33
+ uses : " actions/checkout@v4 "
33
34
with :
34
35
fetch-depth : 2
35
36
47
48
args : extra.symfony.require ${{ matrix.symfony-version }}
48
49
49
50
- name : " Install dependencies with Composer"
50
- uses : " ramsey/composer-install@v1 "
51
+ uses : " ramsey/composer-install@v3 "
51
52
with :
52
53
dependency-versions : " ${{ matrix.dependencies }}"
53
54
composer-options : " ${{ matrix.composer-options }}"
Original file line number Diff line number Diff line change 18
18
19
19
{{ " foo.bar4" | transchoice(5 , {' %name%' : ' Johannes' }, ' app' ) }}
20
20
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 17
17
{{ " foo.bar4" | trans({' %count%' : 5 , ' %name%' : ' Johannes' }, ' app' ) }}
18
18
19
19
{% 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()
99
99
$ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 19 ));
100
100
$ expected ->add ($ message );
101
101
102
+ $ message = new Message ('foo.bar5 ' , 'app ' );
103
+ $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 21 ));
104
+ $ expected ->add ($ message );
105
+
102
106
$ this ->assertEquals ($ expected , $ this ->extract ('simple_template_sf5.html.twig ' ));
103
107
}
104
108
@@ -162,6 +166,10 @@ public function testExtractSimpleTemplate()
162
166
$ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 21 ));
163
167
$ expected ->add ($ message );
164
168
169
+ $ message = new Message ('foo.bar5 ' , 'app ' );
170
+ $ message ->addSource ($ fileSourceFactory ->create ($ fixtureSplInfo , 23 ));
171
+ $ expected ->add ($ message );
172
+
165
173
$ this ->assertEquals ($ expected , $ this ->extract ('simple_template.html.twig ' ));
166
174
}
167
175
Original file line number Diff line number Diff line change 27
27
use JMS \TranslationBundle \Translation \FileSourceFactory ;
28
28
use Symfony \Bridge \Twig \Node \TransNode ;
29
29
use Twig \Environment ;
30
+ use Twig \Node \Expression \AbstractExpression ;
30
31
use Twig \Node \Expression \ConstantExpression ;
31
32
use Twig \Node \Expression \FilterExpression ;
32
33
use Twig \Node \Node ;
@@ -97,11 +98,11 @@ protected function doEnterNode(Node $node, Environment $env)
97
98
}
98
99
$ id = $ idNode ->getAttribute ('value ' );
99
100
100
- $ index = $ name === 'trans ' ? 1 : 2 ;
101
101
$ domain = 'messages ' ;
102
102
$ 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 ) {
105
106
if (! $ argument instanceof ConstantExpression) {
106
107
return $ node ;
107
108
@@ -145,6 +146,20 @@ protected function doEnterNode(Node $node, Environment $env)
145
146
return $ node ;
146
147
}
147
148
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
+
148
163
/**
149
164
* @return int
150
165
*/
Original file line number Diff line number Diff line change 17
17
</testsuite >
18
18
</testsuites >
19
19
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
+
20
25
<filter >
21
26
<whitelist >
22
27
<directory >./</directory >
You can’t perform that action at this time.
0 commit comments