|
33 | 33 | use Symfony\Component\Console\Output\NullOutput;
|
34 | 34 | use Symfony\Component\Console\Output\OutputInterface;
|
35 | 35 | use Symfony\Component\Console\Style\SymfonyStyle;
|
| 36 | +use Symfony\Component\Translation\MessageCatalogueInterface; |
36 | 37 |
|
37 | 38 | class TranslationExtractCommand extends Command
|
38 | 39 | {
|
@@ -65,14 +66,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int
|
65 | 66 | ];
|
66 | 67 | $end = $input->getOption('all') ? sizeof(self::LOCALES) : 1;
|
67 | 68 | for ($i = 0; $i < $end; $i++) {
|
68 |
| - $args['locale'] = self::LOCALES[$i]; |
| 69 | + $locale = self::LOCALES[$i]; |
| 70 | + $args['locale'] = $locale; |
69 | 71 | $code = $updateCmd->run(new ArrayInput($args), new NullOutput());
|
70 | 72 | if ($code == Command::FAILURE) {
|
71 |
| - array_push($failures, self::LOCALES[$i]); |
| 73 | + array_push($failures, $locale); |
| 74 | + } else { |
| 75 | + $file = sprintf( |
| 76 | + 'translations/%s%s.%s.%s', |
| 77 | + self::DOMAIN, |
| 78 | + MessageCatalogueInterface::INTL_DOMAIN_SUFFIX, |
| 79 | + $locale, |
| 80 | + self::FORMAT |
| 81 | + ); |
| 82 | + exec("vendor/bin/phpcbf $file"); |
72 | 83 | }
|
73 | 84 | }
|
74 | 85 | if (sizeof($failures) === 0) {
|
75 |
| - $io->success('The translations have been correcty extracted'); |
| 86 | + // phpcs:ignore Generic.Files.LineLength |
| 87 | + $io->success('The translations have been correcty extracted. Edit the new values and remove the untranslated ones.'); |
76 | 88 | return Command::SUCCESS;
|
77 | 89 | } else {
|
78 | 90 | $vars = implode(', ', $failures);
|
|
0 commit comments