Skip to content

Commit d1cc2a7

Browse files
Nyholmnicolas-grekas
authored andcommitted
[Translator] Deprecated transChoice and moved it away from contracts
1 parent e475dae commit d1cc2a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Extension/TranslationExtension.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Symfony\Bridge\Twig\TokenParser\TransChoiceTokenParser;
1717
use Symfony\Bridge\Twig\TokenParser\TransDefaultDomainTokenParser;
1818
use Symfony\Bridge\Twig\TokenParser\TransTokenParser;
19+
use Symfony\Component\Translation\LegacyTranslatorTrait;
20+
use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
1921
use Symfony\Contracts\Translation\TranslatorInterface;
2022
use Symfony\Contracts\Translation\TranslatorTrait;
2123
use Twig\Extension\AbstractExtension;
@@ -34,6 +36,9 @@ class TranslationExtension extends AbstractExtension
3436
getLocale as private;
3537
setLocale as private;
3638
trans as private doTrans;
39+
}
40+
41+
use LegacyTranslatorTrait {
3742
transChoice as private doTransChoice;
3843
}
3944

@@ -107,7 +112,7 @@ public function trans($message, array $arguments = array(), $domain = null, $loc
107112

108113
public function transchoice($message, $count, array $arguments = array(), $domain = null, $locale = null)
109114
{
110-
if (null === $this->translator) {
115+
if (null === $this->translator || !$this->translator instanceof LegacyTranslatorInterface) {
111116
return $this->doTransChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
112117
}
113118

0 commit comments

Comments
 (0)