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

Appearance settings

Commit 2ba8b8f

Browse filesBrowse files
[Bridge\Twig] lazy load TranslatorTrait
1 parent fc007fc commit 2ba8b8f
Copy full SHA for 2ba8b8f

File tree

Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed

‎src/Symfony/Bridge/Twig/Extension/TranslationExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@
3333
*/
3434
class TranslationExtension extends AbstractExtension
3535
{
36-
use TranslatorTrait {
37-
getLocale as private;
38-
setLocale as private;
39-
trans as private doTrans;
40-
}
41-
4236
private $translator;
4337
private $translationNodeVisitor;
4438

@@ -115,7 +109,9 @@ public function trans($message, array $arguments = [], $domain = null, $locale =
115109
$arguments['%count%'] = $count;
116110
}
117111
if (null === $this->translator) {
118-
return $this->doTrans($message, $arguments, $domain, $locale);
112+
$this->translator = new class() implements TranslatorInterface {
113+
use TranslatorTrait;
114+
};
119115
}
120116

121117
return $this->translator->trans($message, $arguments, $domain, $locale);
@@ -127,8 +123,11 @@ public function trans($message, array $arguments = [], $domain = null, $locale =
127123
public function transchoice($message, $count, array $arguments = [], $domain = null, $locale = null)
128124
{
129125
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+
};
131129
}
130+
132131
if ($this->translator instanceof TranslatorInterface) {
133132
return $this->translator->trans($message, array_merge(['%count%' => $count], $arguments), $domain, $locale);
134133
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.