/** * Convert the source file to the destination file. * * @param XLiffFile $src The source XLIFF file. * * @param ContaoFile $dst The destination Contao file. * * @return bool */ protected function convert(XLiffFile $src, ContaoFile $dst) { $changed = false; foreach ($src->getKeys() as $key) { if (($value = $src->getTarget($key)) !== null) { if ($dst->getValue($key) != $value) { $changed = true; $dst->setValue($key, $value); } } else { if ($dst->getValue($key) !== null) { $changed = true; $dst->removeValue($key); } } } return $changed; }
/** * Convert the source file to the destination file. * * @param OutputInterface $output An OutputInterface instance. * * @param ContaoFile $src The source Contao file. * * @param XLiffFile $dst The destination XLIFF file. * * @param ContaoFile $base The base Contao file. * * @return void */ protected function convert(OutputInterface $output, ContaoFile $src, XLiffFile $dst, ContaoFile $base) { $baseKeys = $base->getKeys(); foreach ($baseKeys as $key) { if (!($basVal = $base->getValue($key))) { $dst->remove($key); continue; } $dst->setSource($key, $basVal); if (($value = $src->getValue($key)) !== null) { $dst->setTarget($key, $value); } } foreach ($dst->getKeys() as $key) { if (!in_array($key, $baseKeys)) { $this->writelnVerbose($output, sprintf('Language key <info>%s</info> is not present in the source. Removing it.', $key)); $dst->remove($key); } } }