Skip to content

Commit bc6ad00

Browse files
VincentLangletnicolas-grekas
authored andcommitted
[Translation] fix support of TranslatableInterface in IdentityTranslator
1 parent cd2e033 commit bc6ad00

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Tests/Extension/Fixtures/StubTranslator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111

1212
namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures;
1313

14+
use Symfony\Contracts\Translation\TranslatableInterface;
1415
use Symfony\Contracts\Translation\TranslatorInterface;
1516

1617
class StubTranslator implements TranslatorInterface
1718
{
1819
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
1920
{
21+
foreach ($parameters as $k => $v) {
22+
if ($v instanceof TranslatableInterface) {
23+
$parameters[$k] = $v->trans($this, $locale);
24+
}
25+
}
26+
2027
return '[trans]'.strtr($id, $parameters).'[/trans]';
2128
}
2229

0 commit comments

Comments
 (0)