33
33
*/
34
34
class TranslationExtension extends AbstractExtension
35
35
{
36
- use TranslatorTrait {
37
- getLocale as private ;
38
- setLocale as private ;
39
- trans as private doTrans;
40
- }
41
-
42
36
private $ translator ;
43
37
private $ translationNodeVisitor ;
44
38
@@ -115,7 +109,9 @@ public function trans($message, array $arguments = [], $domain = null, $locale =
115
109
$ arguments ['%count% ' ] = $ count ;
116
110
}
117
111
if (null === $ this ->translator ) {
118
- return $ this ->doTrans ($ message , $ arguments , $ domain , $ locale );
112
+ $ this ->translator = new class () implements TranslatorInterface {
113
+ use TranslatorTrait;
114
+ };
119
115
}
120
116
121
117
return $ this ->translator ->trans ($ message , $ arguments , $ domain , $ locale );
@@ -127,8 +123,11 @@ public function trans($message, array $arguments = [], $domain = null, $locale =
127
123
public function transchoice ($ message , $ count , array $ arguments = [], $ domain = null , $ locale = null )
128
124
{
129
125
if (null === $ this ->translator ) {
130
- return $ this ->doTrans ($ message , array_merge (['%count% ' => $ count ], $ arguments ), $ domain , $ locale );
126
+ $ this ->translator = new class () implements TranslatorInterface {
127
+ use TranslatorTrait;
128
+ };
131
129
}
130
+
132
131
if ($ this ->translator instanceof TranslatorInterface) {
133
132
return $ this ->translator ->trans ($ message , array_merge (['%count% ' => $ count ], $ arguments ), $ domain , $ locale );
134
133
}
0 commit comments