From f63e8433cff3a7d2a9a9fe1e18279633d522c6d4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 29 Nov 2019 13:21:45 +0100 Subject: [PATCH] Fix the translation commands when a template contains a syntax error --- .../Command/TranslationDebugCommand.php | 10 +++++++--- .../Command/TranslationUpdateCommand.php | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php index 33b984663681c..2c47a5a4d7a77 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -204,7 +204,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } // Extract used messages - $extractedCatalogue = $this->extractMessages($locale, $viewsPaths); + $extractedCatalogue = $this->extractMessages($io->getErrorStyle(), $locale, $viewsPaths); // Load defined messages $currentCatalogue = $this->loadCurrentMessages($locale, $transPaths); @@ -330,12 +330,16 @@ private function sanitizeString($string, $length = 40) * * @return MessageCatalogue */ - private function extractMessages($locale, $transPaths) + private function extractMessages(SymfonyStyle $errorIo, $locale, $transPaths) { $extractedCatalogue = new MessageCatalogue($locale); foreach ($transPaths as $path) { if (is_dir($path)) { - $this->extractor->extract($path, $extractedCatalogue); + try { + $this->extractor->extract($path, $extractedCatalogue); + } catch (\Exception $e) { + $errorIo->warning($e->getMessage()); + } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index 7375450d5d219..9ce51e737bac1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -215,7 +215,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->extractor->setPrefix($prefix); foreach ($viewsPaths as $path) { if (is_dir($path)) { - $this->extractor->extract($path, $extractedCatalogue); + try { + $this->extractor->extract($path, $extractedCatalogue); + } catch (\Exception $e) { + $errorIo->warning($e->getMessage()); + } } }