From 67fba12b388e4ffd1df80bab1ca39f50eced9622 Mon Sep 17 00:00:00 2001 From: Alexis Date: Mon, 9 Sep 2024 10:58:46 +0200 Subject: [PATCH] Fix : translate message sent in log file --- Import.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Import.php b/Import.php index 5323647..38f81f5 100644 --- a/Import.php +++ b/Import.php @@ -21,12 +21,14 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class Import implements ImportInterface { protected ConfigurationInterface $configuration; protected Connection $connection; protected EventDispatcherInterface $dispatcher; + protected TranslatorInterface $translator; protected LoggerInterface $logger; protected Collection $config; protected StrategyRepositoryInterface $strategyRepository; @@ -41,6 +43,7 @@ public function __construct( StrategyRepositoryInterface $strategyRepository, LoadStrategyRepositoryInterface $loadStrategyRepository, ConfigurationInterface $configuration, + TranslatorInterface $translator, ?LoggerInterface $logger = null ) { $this->configuration = $configuration; @@ -48,6 +51,7 @@ public function __construct( $this->dispatcher = $dispatcher; $this->strategyRepository = $strategyRepository; $this->loadStrategyRepository = $loadStrategyRepository; + $this->translator = $translator; $this->logger = $logger ?? new NullLogger(); $this->loaders = new ArrayCollection(); } @@ -199,10 +203,10 @@ private function loadResource(ImportResource $resource): bool } if (($count = $this->loadData($resource, $file)) !== 0) { - $this->logger->notice('{file}: {count} lines loaded', [ - 'file' => $file->getBasename(), - 'count' => $count, ] - ); + $this->logger->notice($this->translator->trans('{file}: {count} lines loaded', [ + '{file}' => $file->getBasename(), + '{count}' => $count, + ])); $loaded = true; } }