Skip to content

Commit

Permalink
[translator] Use DrupalStyle to show erros (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjuarez20 authored and enzolutions committed May 23, 2019
1 parent 934d14f commit 4914556
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Utils/TranslatorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,13 +50,22 @@ class TranslatorManager implements TranslatorManagerInterface
*/
protected $coreLanguageRoot;

/**
* @var DrupalStyle
*/
private $io;

/**
* Translator constructor.
*/
public function __construct()
{
$this->parser = new Parser();
$this->filesystem = new Filesystem();

$output = new ConsoleOutput();
$input = new ArrayInput([]);
$this->io = new DrupalStyle($input, $output);
}

/**
Expand Down Expand Up @@ -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;
Expand All @@ -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());
}
}

Expand Down

0 comments on commit 4914556

Please sign in to comment.