protected function execute(InputInterface $input, OutputInterface $output) { $files = $input->getArgument('files'); if (!$files) { $files = array(getcwd()); } $iterator = new RecursiveSourcesIterator($files); if (!$input->getOption('dotfiles')) { $iterator = new DotfilesFilter($iterator); } $scanner = new TreeScanner($output); $scanner->scanTree($iterator); $strings = $scanner->getStrings(); $output->writeln("<info>{$strings->count()} translatable strings detected</info>"); $locales = new CsvFilter(new \RecursiveIteratorIterator($iterator)); $csvCount = iterator_count($locales); $output->writeln("<info>{$csvCount} CSV file(s) found</info>"); /* @var $locale SourceFileInfo */ foreach ($locales as $locale) { $csv = new Strings(); $csv->fromCsvFile($locale->getPathname()); $add = $strings->subtract($csv); $delete = $csv->subtract($strings); if ($add->count() || $delete->count()) { $output->writeln("<info>Adding {$add->count()} strings to and removing {$delete->count()} strings from {$locale->getRelativePathname()}</info>"); $csv->merge($add)->subtract($delete)->toCsvFile($locale->getPathname()); } } }
protected function execute(InputInterface $input, OutputInterface $output) { $files = $input->getArgument('files'); if (!$files) { $files = array(getcwd()); } $iterator = new RecursiveSourcesIterator($files); if (!$input->getOption('dotfiles')) { $iterator = new DotfilesFilter($iterator); } $scanner = new TreeScanner($output); $scanner->scanTree($iterator); $strings = $scanner->getStrings(); $output->writeln($strings->toCsvArray()); }
/** * Scan $files for translatable content * * @param \Traversable $files * @param OutputInterface $output * @return \MageI18n\Strings */ protected function getStrings(\Traversable $files, OutputInterface $output) { $scanner = new TreeScanner($output); $scanner->scanTree($files); return $scanner->getStrings(); }