Skip to content

Commit 4914556

Browse files
hjuarez20enzolutions
authored andcommitted
[translator] Use DrupalStyle to show erros (#352)
1 parent 934d14f commit 4914556

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Utils/TranslatorManager.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace Drupal\Console\Core\Utils;
99

10+
use Drupal\Console\Core\Style\DrupalStyle;
11+
use Symfony\Component\Console\Input\ArrayInput;
12+
use Symfony\Component\Console\Output\ConsoleOutput;
1013
use Symfony\Component\Translation\Translator;
1114
use Symfony\Component\Translation\Loader\YamlFileLoader;
1215
use Symfony\Component\Translation\Loader\ArrayLoader;
@@ -47,13 +50,22 @@ class TranslatorManager implements TranslatorManagerInterface
4750
*/
4851
protected $coreLanguageRoot;
4952

53+
/**
54+
* @var DrupalStyle
55+
*/
56+
private $io;
57+
5058
/**
5159
* Translator constructor.
5260
*/
5361
public function __construct()
5462
{
5563
$this->parser = new Parser();
5664
$this->filesystem = new Filesystem();
65+
66+
$output = new ConsoleOutput();
67+
$input = new ArrayInput([]);
68+
$this->io = new DrupalStyle($input, $output);
5769
}
5870

5971
/**
@@ -164,7 +176,7 @@ public function loadResource($language, $directoryRoot)
164176
try {
165177
$this->loadTranslationByFile($resource, 'application');
166178
} catch (ParseException $e) {
167-
echo 'application.yml'.' '.$e->getMessage();
179+
$this->io->error('application.yml'.' '.$e->getMessage());
168180
}
169181

170182
continue;
@@ -173,7 +185,7 @@ public function loadResource($language, $directoryRoot)
173185
try {
174186
$this->loadTranslationByFile($resource, $key);
175187
} catch (ParseException $e) {
176-
echo $key.'.yml '.$e->getMessage();
188+
$this->io->error($key.'.yml '.$e->getMessage());
177189
}
178190
}
179191

0 commit comments

Comments
 (0)