Skip to content

Commit 1afa52a

Browse files
bug #61111 [Translation] fix support of TranslatableInterface in IdentityTranslator (VincentLanglet)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- [Translation] fix support of `TranslatableInterface` in `IdentityTranslator` | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- if yes, also update src/**/CHANGELOG.md --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | Fix #... <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below --> | License | MIT Commits ------- 92ae810d730 [Translation] fix support of `TranslatableInterface` in `IdentityTranslator`
2 parents 09c9677 + bc6ad00 commit 1afa52a

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)