4 * This file is part of the Behat Testwork.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Testwork\Translator\Cli;
13 use Behat\Testwork\Cli\Controller;
14 use Symfony\Component\Console\Command\Command;
15 use Symfony\Component\Console\Input\InputInterface;
16 use Symfony\Component\Console\Input\InputOption;
17 use Symfony\Component\Console\Output\OutputInterface;
18 use Symfony\Component\Translation\Translator;
21 * Configures translator service to use custom locale.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 final class LanguageController implements Controller
33 * Initializes controller.
35 * @param Translator $translator
37 public function __construct(Translator $translator)
39 $this->translator = $translator;
45 public function configure(Command $command)
47 $command->addOption('--lang', null, InputOption::VALUE_REQUIRED,
48 'Print output in particular language.'
55 public function execute(InputInterface $input, OutputInterface $output)
57 if (!$input->getOption('lang')) {
61 $this->translator->setLocale($input->getOption('lang'));