‪TYPO3CMS  9.5
LanguagePackCommand.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 use Symfony\Component\Console\Command\Command;
19 use Symfony\Component\Console\Helper\ProgressBar;
20 use Symfony\Component\Console\Input\InputArgument;
21 use Symfony\Component\Console\Input\InputInterface;
22 use Symfony\Component\Console\Output\NullOutput;
23 use Symfony\Component\Console\Output\OutputInterface;
27 
31 class ‪LanguagePackCommand extends Command
32 {
36  protected function ‪configure()
37  {
38  $this->setAliases(['lang:language:update']);
39  $this->setDescription('Update the language files of all activated extensions')
40  ->addArgument(
41  'locales',
42  InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
43  'Provide iso codes separated by space to update only selected language packs. Example `bin/typo3 language:update de ja`.'
44  );
45  }
46 
56  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
57  {
58  if ($input->hasArgument('command') && substr_count($input->getArgument('command'), ':') === 2) {
59  $message = 'bin/typo3 lang:language:update is deprecated, use bin/typo3 language:update instead';
60  ‪$output->writeln('<error>' . $message . '</error>');
61  trigger_error($message, E_USER_DEPRECATED);
62  }
63 
64  $languagePackService = GeneralUtility::makeInstance(LanguagePackService::class);
65 
66  try {
67  $isos = $input->getArgument('locales');
68  } catch (\‪Exception $e) {
69  $isos = [];
70  }
71  if (empty($isos)) {
72  $isos = $languagePackService->getActiveLanguages();
73  }
74 
75  if (‪$output->isVerbose()) {
76  ‪$output->writeln(sprintf(
77  '<info>Updating language packs of all activated extensions for locale(s) "%s"</info>',
78  implode('", "', $isos)
79  ));
80  }
81 
82  $extensions = $languagePackService->getExtensionLanguagePackDetails();
83 
84  if (!‪$output->isVerbose()) {
85  $progressBarOutput = new NullOutput();
86  } else {
87  $progressBarOutput = ‪$output;
88  }
89  $progressBar = new ProgressBar($progressBarOutput, count($isos) * count($extensions));
90  $languagePackService->updateMirrorBaseUrl();
91  foreach ($isos as $iso) {
92  foreach ($extensions as $extension) {
93  $languagePackService->languagePackDownload($extension['key'], $iso);
94  $progressBar->advance();
95  }
96  }
97  $languagePackService->setLastUpdatedIsoCode($isos);
98  $progressBar->finish();
99 
100  // Flush language cache
101  GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
102 
103  return 0;
104  }
105 }
‪TYPO3\CMS\Install\Command\LanguagePackCommand\configure
‪configure()
Definition: LanguagePackCommand.php:36
‪TYPO3\CMS\Install\Command\LanguagePackCommand
Definition: LanguagePackCommand.php:32
‪TYPO3\CMS\Install\Command
Definition: LanguagePackCommand.php:3
‪TYPO3\CMS\Install\Exception
Definition: Exception.php:23
‪TYPO3\CMS\Install\Command\LanguagePackCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: LanguagePackCommand.php:56
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Install\Service\LanguagePackService
Definition: LanguagePackService.php:38
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45