From 491455688ef6abeed7f155b6f935a10791927c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harold=20Ju=C3=A1rez?= Date: Thu, 23 May 2019 14:57:22 -0600 Subject: [PATCH] [translator] Use DrupalStyle to show erros (#352) --- src/Utils/TranslatorManager.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Utils/TranslatorManager.php b/src/Utils/TranslatorManager.php index 60f2b86..cafb382 100644 --- a/src/Utils/TranslatorManager.php +++ b/src/Utils/TranslatorManager.php @@ -7,6 +7,9 @@ namespace Drupal\Console\Core\Utils; +use Drupal\Console\Core\Style\DrupalStyle; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\YamlFileLoader; use Symfony\Component\Translation\Loader\ArrayLoader; @@ -47,6 +50,11 @@ class TranslatorManager implements TranslatorManagerInterface */ protected $coreLanguageRoot; + /** + * @var DrupalStyle + */ + private $io; + /** * Translator constructor. */ @@ -54,6 +62,10 @@ public function __construct() { $this->parser = new Parser(); $this->filesystem = new Filesystem(); + + $output = new ConsoleOutput(); + $input = new ArrayInput([]); + $this->io = new DrupalStyle($input, $output); } /** @@ -164,7 +176,7 @@ public function loadResource($language, $directoryRoot) try { $this->loadTranslationByFile($resource, 'application'); } catch (ParseException $e) { - echo 'application.yml'.' '.$e->getMessage(); + $this->io->error('application.yml'.' '.$e->getMessage()); } continue; @@ -173,7 +185,7 @@ public function loadResource($language, $directoryRoot) try { $this->loadTranslationByFile($resource, $key); } catch (ParseException $e) { - echo $key.'.yml '.$e->getMessage(); + $this->io->error($key.'.yml '.$e->getMessage()); } }