protected function execute(InputInterface $input, OutputInterface $output)
 {
     $builder = $input->getOption('config') ? $this->getContainer()->get('jms_translation.config_factory')->getBuilder($input->getOption('config')) : new ConfigBuilder();
     $config = $this->getConfigFromInput($input, $builder);
     $output->writeln(sprintf('Keep old translations: <info>%s</info>', $config->isKeepOldMessages() ? 'Yes' : 'No'));
     $output->writeln(sprintf('Output-Path: <info>%s</info>', $config->getTranslationsDir()));
     $output->writeln(sprintf('Directories: <info>%s</info>', implode(', ', $config->getScanDirs())));
     $output->writeln(sprintf('Excluded Directories: <info>%s</info>', $config->getExcludedDirs() ? implode(', ', $config->getExcludedDirs()) : '# none #'));
     $output->writeln(sprintf('Excluded Names: <info>%s</info>', $config->getExcludedNames() ? implode(', ', $config->getExcludedNames()) : '# none #'));
     $output->writeln(sprintf('Output-Format: <info>%s</info>', $config->getOutputFormat() ? $config->getOutputFormat() : '# whatever is present, if nothing then ' . $config->getDefaultOutputFormat() . ' #'));
     $output->writeln(sprintf('Custom Extractors: <info>%s</info>', $config->getEnabledExtractors() ? implode(', ', array_keys($config->getEnabledExtractors())) : '# none #'));
     $output->writeln('============================================================');
     $updater = $this->getContainer()->get('jms_translation.updater');
     $updater->setLogger($logger = new OutputLogger($output));
     if (!$input->getOption('verbose')) {
         $logger->setLevel(OutputLogger::ALL ^ OutputLogger::DEBUG);
     }
     if ($input->getOption('dry-run')) {
         $changeSet = $updater->getChangeSet($config);
         $output->writeln('Added Messages: ' . implode(', ', array_keys($changeSet->getAddedMessages())));
         if ($config->isKeepOldMessages()) {
             $output->writeln('Deleted Messages: # none as "Keep Old Translations" is true #');
         } else {
             $output->writeln('Deleted Messages: ' . implode(', ', array_keys($changeSet->getDeletedMessages())));
         }
         return;
     }
     $updater->process($config);
     $output->writeln('done!');
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $builder = $input->getOption('config') ? $this->getContainer()->get('jms_translation.config_factory')->getBuilder($input->getOption('config')) : new ConfigBuilder();
     $this->updateWithInput($input, $builder);
     $locales = $input->getArgument('locales');
     if (empty($locales)) {
         $locales = $this->getContainer()->getParameter('jms_translation.locales');
     }
     if (empty($locales)) {
         throw new \LogicException('No locales were given, and no locales are configured.');
     }
     foreach ($locales as $locale) {
         $config = $builder->setLocale($locale)->getConfig();
         $output->writeln(sprintf('Extracting Translations for locale <info>%s</info>', $locale));
         $output->writeln(sprintf('Keep old translations: <info>%s</info>', $config->isKeepOldMessages() ? 'Yes' : 'No'));
         $output->writeln(sprintf('Keep old translation messages: <info>%s</info>', $config->isKeepOldTranslationMessages() ? 'Yes' : 'No'));
         $output->writeln(sprintf('Output-Path: <info>%s</info>', $config->getTranslationsDir()));
         $output->writeln(sprintf('Directories: <info>%s</info>', implode(', ', $config->getScanDirs())));
         $output->writeln(sprintf('Excluded Directories: <info>%s</info>', $config->getExcludedDirs() ? implode(', ', $config->getExcludedDirs()) : '# none #'));
         $output->writeln(sprintf('Excluded Names: <info>%s</info>', $config->getExcludedNames() ? implode(', ', $config->getExcludedNames()) : '# none #'));
         $output->writeln(sprintf('Output-Format: <info>%s</info>', $config->getOutputFormat() ? $config->getOutputFormat() : '# whatever is present, if nothing then ' . $config->getDefaultOutputFormat() . ' #'));
         $output->writeln(sprintf('Custom Extractors: <info>%s</info>', $config->getEnabledExtractors() ? implode(', ', array_keys($config->getEnabledExtractors())) : '# none #'));
         $output->writeln('============================================================');
         $updater = $this->getContainer()->get('jms_translation.updater');
         $updater->setLogger($logger = new OutputLogger($output));
         if (!$input->getOption('verbose')) {
             $logger->setLevel(OutputLogger::ALL ^ OutputLogger::DEBUG);
         }
         if ($input->getOption('dry-run')) {
             $changeSet = $updater->getChangeSet($config);
             $output->writeln('Added Messages: ' . count($changeSet->getAddedMessages()));
             if ($input->hasParameterOption('--verbose')) {
                 foreach ($changeSet->getAddedMessages() as $message) {
                     $output->writeln($message->getId() . '-> ' . $message->getDesc());
                 }
             }
             if ($config->isKeepOldMessages()) {
                 $output->writeln('Deleted Messages: # none as "Keep Old Translations" is true #');
             } else {
                 $output->writeln('Deleted Messages: ' . count($changeSet->getDeletedMessages()));
                 if ($input->hasParameterOption('--verbose')) {
                     foreach ($changeSet->getDeletedMessages() as $message) {
                         $output->writeln($message->getId() . '-> ' . $message->getDesc());
                     }
                 }
             }
             if ($config->isKeepOldTranslationMessages()) {
                 $output->writeln('Not keeping old Translation Messages');
             }
             return;
         }
         $updater->process($config);
     }
     $output->writeln('done!');
 }
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $builder = new ConfigBuilder();
     $builder->setOutputFormat('xlf')->setTranslationsDir(__DIR__ . '/../../../../../resources/locales')->setScanDirs([$this->container['root.path'] . '/lib', $this->container['root.path'] . '/templates', $this->container['root.path'] . '/bin', $this->container['root.path'] . '/www']);
     if ($input->hasParameterOption('--keep') || $input->hasParameterOption('--keep=true')) {
         $builder->setKeepOldTranslations(true);
     } else {
         if ($input->hasParameterOption('--keep=false')) {
             $builder->setKeepOldTranslations(false);
         }
     }
     $locales = $input->getArgument('locales');
     if (empty($locales)) {
         $locales = array_keys($this->container->getAvailableLanguages());
     }
     if (empty($locales)) {
         throw new \LogicException('No locales were given, and no locales are configured.');
     }
     foreach ($locales as $locale) {
         $config = $builder->setLocale($locale)->getConfig();
         $output->writeln(sprintf('Extracting Translations for locale <info>%s</info>', $locale));
         $output->writeln(sprintf('Keep old translations: <info>%s</info>', $config->isKeepOldMessages() ? 'Yes' : 'No'));
         $output->writeln(sprintf('Output-Path: <info>%s</info>', $config->getTranslationsDir()));
         $output->writeln(sprintf('Directories: <info>%s</info>', implode(', ', $config->getScanDirs())));
         $output->writeln(sprintf('Excluded Directories: <info>%s</info>', $config->getExcludedDirs() ? implode(', ', $config->getExcludedDirs()) : '# none #'));
         $output->writeln(sprintf('Excluded Names: <info>%s</info>', $config->getExcludedNames() ? implode(', ', $config->getExcludedNames()) : '# none #'));
         $output->writeln(sprintf('Output-Format: <info>%s</info>', $config->getOutputFormat() ? $config->getOutputFormat() : '# whatever is present, if nothing then ' . $config->getDefaultOutputFormat() . ' #'));
         $output->writeln(sprintf('Custom Extractors: <info>%s</info>', $config->getEnabledExtractors() ? implode(', ', array_keys($config->getEnabledExtractors())) : '# none #'));
         $output->writeln('============================================================');
         /** @var Updater $updater */
         $updater = $this->container['translation-extractor.updater'];
         $updater->setLogger($logger = new OutputLogger($output));
         if (!$input->getOption('verbose')) {
             $logger->setLevel(OutputLogger::ALL ^ OutputLogger::DEBUG);
         }
         if ($input->getOption('dry-run')) {
             /** @var ChangeSet $changeSet */
             $changeSet = $updater->getChangeSet($config);
             $output->writeln('Added Messages: ' . count($changeSet->getAddedMessages()));
             if ($input->getOption('verbose')) {
                 /** @var Message $message */
                 foreach ($changeSet->getAddedMessages() as $message) {
                     $output->writeln($message->getId() . '-> ' . $message->getDesc());
                 }
             }
             if ($config->isKeepOldMessages()) {
                 $output->writeln('Deleted Messages: # none as "Keep Old Translations" is true #');
             } else {
                 $output->writeln('Deleted Messages: ' . count($changeSet->getDeletedMessages()));
                 if ($input->getOption('verbose')) {
                     foreach ($changeSet->getDeletedMessages() as $message) {
                         $output->writeln($message->getId() . '-> ' . $message->getDesc());
                     }
                 }
             }
             return 0;
         }
         $updater->process($config);
     }
     $output->writeln('done!');
     return 0;
 }