Skip to content

Commit e2674a3

Browse files
committed
fix translation lint compatibility with the PseudoLocalizationTranslator
1 parent dc89e16 commit e2674a3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

PseudoLocalizationTranslator.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111

1212
namespace Symfony\Component\Translation;
1313

14+
use Symfony\Component\Translation\Exception\LogicException;
1415
use Symfony\Contracts\Translation\TranslatorInterface;
1516

1617
/**
1718
* This translator should only be used in a development environment.
1819
*/
19-
final class PseudoLocalizationTranslator implements TranslatorInterface
20+
final class PseudoLocalizationTranslator implements TranslatorInterface, TranslatorBagInterface
2021
{
2122
private const EXPANSION_CHARACTER = '~';
2223

@@ -115,6 +116,24 @@ public function getLocale(): string
115116
return $this->translator->getLocale();
116117
}
117118

119+
public function getCatalogue(?string $locale = null): MessageCatalogueInterface
120+
{
121+
if (!$this->translator instanceof TranslatorBagInterface) {
122+
throw new LogicException(\sprintf('The "%s()" method cannot be called as the wrapped translator class "%s" does not implement the "%s".', __METHOD__, $this->translator::class, TranslatorBagInterface::class));
123+
}
124+
125+
return $this->translator->getCatalogue($locale);
126+
}
127+
128+
public function getCatalogues(): array
129+
{
130+
if (!$this->translator instanceof TranslatorBagInterface) {
131+
throw new LogicException(\sprintf('The "%s()" method cannot be called as the wrapped translator class "%s" does not implement the "%s".', __METHOD__, $this->translator::class, TranslatorBagInterface::class));
132+
}
133+
134+
return $this->translator->getCatalogues();
135+
}
136+
118137
private function getParts(string $originalTrans): array
119138
{
120139
if (!$this->parseHTML) {

0 commit comments

Comments
 (0)