/** * This writes any updates to the disk. * * This will not change files of ignored domains. It will also not * change files of another than the current locale. * * @param Config $config */ public function process(Config $config) { $this->setConfig($config); foreach ($this->scannedCatalogue->getDomains() as $name => $domain) { // skip domain not selected if ($this->config->hasDomains() && !$this->config->hasDomain($name)) { continue; } if ($this->config->isIgnoredDomain($name)) { continue; } $format = $this->detectOutputFormat($name); // delete translation files of other formats foreach (Finder::create()->name('/^' . $name . '\\.' . $this->config->getLocale() . '\\.[^\\.]+$/')->in($this->config->getTranslationsDir())->depth('< 1')->files() as $file) { if ('.' . $format === substr($file, -1 * strlen('.' . $format))) { continue; } $this->logger->info(sprintf('Deleting translation file "%s".', $file)); if (false === @unlink($file)) { throw new RuntimeException(sprintf('Could not delete the translation file "%s".', $file)); } } $outputFile = $this->config->getTranslationsDir() . '/' . $name . '.' . $this->config->getLocale() . '.' . $format; $this->logger->info(sprintf('Writing translation file "%s".', $outputFile)); $this->writer->write($this->scannedCatalogue, $name, $outputFile, $format); } }