setAliases(['lang:language:update']);
$this->setDescription('Update the language files of all activated extensions')
->addArgument(
'locales',
InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
'Provide iso codes separated by space to update only selected language packs. Example `bin/typo3 language:update de ja`.'
);
}
/**
* Update language packs of all active languages for all active extensions
*
* @param InputInterface $input
* @param OutputInterface $output
* @throws \InvalidArgumentException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->hasArgument('command') && substr_count($input->getArgument('command'), ':') === 2) {
$message = 'bin/typo3 lang:language:update is deprecated, use bin/typo3 language:update instead';
$output->writeln('' . $message . '');
trigger_error($message, E_USER_DEPRECATED);
}
$languagePackService = GeneralUtility::makeInstance(LanguagePackService::class);
try {
$isos = $input->getArgument('locales');
} catch (\Exception $e) {
$isos = [];
}
if (empty($isos)) {
$isos = $languagePackService->getActiveLanguages();
}
if ($output->isVerbose()) {
$output->writeln(sprintf(
'Updating language packs of all activated extensions for locale(s) "%s"',
implode('", "', $isos)
));
}
$extensions = $languagePackService->getExtensionLanguagePackDetails();
if (!$output->isVerbose()) {
$progressBarOutput = new NullOutput();
} else {
$progressBarOutput = $output;
}
$progressBar = new ProgressBar($progressBarOutput, count($isos) * count($extensions));
$languagePackService->updateMirrorBaseUrl();
foreach ($isos as $iso) {
foreach ($extensions as $extension) {
$languagePackService->languagePackDownload($extension['key'], $iso);
$progressBar->advance();
}
}
$languagePackService->setLastUpdatedIsoCode($isos);
$progressBar->finish();
// Flush language cache
GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
return 0;
}
}