Skip to content

Commit

Permalink
fix translation lint compatibility with the PseudoLocalizationTranslator
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Dec 7, 2024
1 parent dc89e16 commit e2674a3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion PseudoLocalizationTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

namespace Symfony\Component\Translation;

use Symfony\Component\Translation\Exception\LogicException;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* This translator should only be used in a development environment.
*/
final class PseudoLocalizationTranslator implements TranslatorInterface
final class PseudoLocalizationTranslator implements TranslatorInterface, TranslatorBagInterface
{
private const EXPANSION_CHARACTER = '~';

Expand Down Expand Up @@ -115,6 +116,24 @@ public function getLocale(): string
return $this->translator->getLocale();
}

public function getCatalogue(?string $locale = null): MessageCatalogueInterface
{
if (!$this->translator instanceof TranslatorBagInterface) {
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));
}

return $this->translator->getCatalogue($locale);
}

public function getCatalogues(): array
{
if (!$this->translator instanceof TranslatorBagInterface) {
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));
}

return $this->translator->getCatalogues();
}

private function getParts(string $originalTrans): array
{
if (!$this->parseHTML) {
Expand Down

0 comments on commit e2674a3

Please sign in to comment.