Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 562b2ed

Browse filesBrowse files
committed
Rename translation:update to translation:extract
1 parent 2771d6e commit 562b2ed
Copy full SHA for 562b2ed

File tree

9 files changed

+35
-26
lines changed
Filter options

9 files changed

+35
-26
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CHANGELOG
1717
* Add `configureContainer()`, `configureRoutes()`, `getConfigDir()` and `getBundlesPath()` to `MicroKernelTrait`
1818
* Add support for configuring log level, and status code by exception class
1919
* Bind the `default_context` parameter onto serializer's encoders and normalizers
20+
* Deprecate `translation:update` command, use `translation:extract` instead
2021

2122
5.3
2223
---

‎src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputArgument;
1717
use Symfony\Component\Console\Input\InputInterface;
1818
use Symfony\Component\Console\Input\InputOption;
19+
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1920
use Symfony\Component\Console\Output\OutputInterface;
2021
use Symfony\Component\Console\Style\SymfonyStyle;
2122
use Symfony\Component\HttpKernel\KernelInterface;
@@ -41,8 +42,8 @@ class TranslationUpdateCommand extends Command
4142
private const DESC = 'desc';
4243
private const SORT_ORDERS = [self::ASC, self::DESC];
4344

44-
protected static $defaultName = 'translation:update';
45-
protected static $defaultDescription = 'Update the translation file';
45+
protected static $defaultName = 'translation:extract|translation:update';
46+
protected static $defaultDescription = 'Extract missing translations keys from code to translation files.';
4647

4748
private $writer;
4849
private $reader;
@@ -80,9 +81,9 @@ protected function configure()
8081
new InputOption('output-format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format (deprecated)'),
8182
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'),
8283
new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'),
83-
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the update be done'),
84+
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'),
8485
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
85-
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
86+
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'),
8687
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version (deprecated)'),
8788
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
8889
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
@@ -126,6 +127,13 @@ protected function configure()
126127
*/
127128
protected function execute(InputInterface $input, OutputInterface $output): int
128129
{
130+
$io = new SymfonyStyle($input, $output);
131+
$errorIo = $output instanceof ConsoleOutputInterface ? new SymfonyStyle($input, $output->getErrorOutput()) : $io;
132+
133+
if ('translation:update' === $input->getFirstArgument()) {
134+
$errorIo->caution('Command "translation:update" is deprecated since version 5.4 and will be removed in Symfony 6.0. Use "translation:extract" instead.');
135+
}
136+
129137
$io = new SymfonyStyle($input, $output);
130138
$errorIo = $io->getErrorStyle();
131139

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
12531253
{
12541254
if (!$this->isConfigEnabled($container, $config)) {
12551255
$container->removeDefinition('console.command.translation_debug');
1256-
$container->removeDefinition('console.command.translation_update');
1256+
$container->removeDefinition('console.command.translation_extract');
12571257
$container->removeDefinition('console.command.translation_pull');
12581258
$container->removeDefinition('console.command.translation_push');
12591259

@@ -1320,8 +1320,8 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
13201320
$container->getDefinition('console.command.translation_debug')->replaceArgument(5, $transPaths);
13211321
}
13221322

1323-
if ($container->hasDefinition('console.command.translation_update')) {
1324-
$container->getDefinition('console.command.translation_update')->replaceArgument(6, $transPaths);
1323+
if ($container->hasDefinition('console.command.translation_extract')) {
1324+
$container->getDefinition('console.command.translation_extract')->replaceArgument(6, $transPaths);
13251325
}
13261326

13271327
if (null === $defaultDir) {

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@
224224
])
225225
->tag('console.command')
226226

227-
->set('console.command.translation_update', TranslationUpdateCommand::class)
227+
->set('console.command.translation_extract', TranslationUpdateCommand::class)
228228
->args([
229229
service('translation.writer'),
230230
service('translation.reader'),

‎src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Command/TranslationUpdateCommandTest.php
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,47 +32,47 @@ class TranslationUpdateCommandTest extends TestCase
3232
public function testDumpMessagesAndClean()
3333
{
3434
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
35-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
35+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
3636
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
3737
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
3838
}
3939

4040
public function testDumpMessagesAsTreeAndClean()
4141
{
4242
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
43-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--as-tree' => 1]);
43+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--as-tree' => 1]);
4444
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
4545
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
4646
}
4747

4848
public function testDumpSortedMessagesAndClean()
4949
{
5050
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
51-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'asc']);
51+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'asc']);
5252
$this->assertMatchesRegularExpression("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
5353
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
5454
}
5555

5656
public function testDumpReverseSortedMessagesAndClean()
5757
{
5858
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
59-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'desc']);
59+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'desc']);
6060
$this->assertMatchesRegularExpression("/\*test\*foo\*bar/", preg_replace('/\s+/', '', $tester->getDisplay()));
6161
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
6262
}
6363

6464
public function testDumpSortWithoutValueAndClean()
6565
{
6666
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
67-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort']);
67+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort']);
6868
$this->assertMatchesRegularExpression("/\*bar\*foo\*test/", preg_replace('/\s+/', '', $tester->getDisplay()));
6969
$this->assertMatchesRegularExpression('/3 messages were successfully extracted/', $tester->getDisplay());
7070
}
7171

7272
public function testDumpWrongSortAndClean()
7373
{
7474
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
75-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'test']);
75+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--sort' => 'test']);
7676
$this->assertMatchesRegularExpression('/\[ERROR\] Wrong sort order/', $tester->getDisplay());
7777
}
7878

@@ -84,15 +84,15 @@ public function testDumpMessagesAndCleanInRootDirectory()
8484
$this->fs->mkdir($this->translationDir.'/templates');
8585

8686
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']], [], null, [$this->translationDir.'/trans'], [$this->translationDir.'/views']);
87-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]);
87+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', '--dump-messages' => true, '--clean' => true]);
8888
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
8989
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
9090
}
9191

9292
public function testDumpTwoMessagesAndClean()
9393
{
9494
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'bar' => 'bar']]);
95-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
95+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true]);
9696
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
9797
$this->assertMatchesRegularExpression('/bar/', $tester->getDisplay());
9898
$this->assertMatchesRegularExpression('/2 messages were successfully extracted/', $tester->getDisplay());
@@ -101,15 +101,15 @@ public function testDumpTwoMessagesAndClean()
101101
public function testDumpMessagesForSpecificDomain()
102102
{
103103
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]);
104-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain']);
104+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--domain' => 'mydomain']);
105105
$this->assertMatchesRegularExpression('/bar/', $tester->getDisplay());
106106
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
107107
}
108108

109109
public function testWriteMessages()
110110
{
111111
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
112-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true]);
112+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--force' => true]);
113113
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
114114
}
115115

@@ -121,14 +121,14 @@ public function testWriteMessagesInRootDirectory()
121121
$this->fs->mkdir($this->translationDir.'/templates');
122122

123123
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
124-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', '--force' => true]);
124+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', '--force' => true]);
125125
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
126126
}
127127

128128
public function testWriteMessagesForSpecificDomain()
129129
{
130130
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo'], 'mydomain' => ['bar' => 'bar']]);
131-
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain']);
131+
$tester->execute(['command' => 'translation:extract', 'locale' => 'en', 'bundle' => 'foo', '--force' => true, '--domain' => 'mydomain']);
132132
$this->assertMatchesRegularExpression('/Translation files were successfully updated./', $tester->getDisplay());
133133
}
134134

@@ -211,7 +211,7 @@ function ($path, $catalogue) use ($loadedMessages) {
211211
$application = new Application($kernel);
212212
$application->add($command);
213213

214-
return new CommandTester($application->find('translation:update'));
214+
return new CommandTester($application->find('translation:extract'));
215215
}
216216

217217
private function getBundle($path)

‎src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/DependencyInjection/TranslatorPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class TranslatorPass implements CompilerPassInterface
2424
private $debugCommandServiceId;
2525
private $updateCommandServiceId;
2626

27-
public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update')
27+
public function __construct(string $translatorServiceId = 'translator.default', string $readerServiceId = 'translation.reader', string $loaderTag = 'translation.loader', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_extract')
2828
{
2929
if (0 < \func_num_args()) {
3030
trigger_deprecation('symfony/translation', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);

‎src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/DependencyInjection/TranslatorPathsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class TranslatorPathsPass extends AbstractRecursivePass
4343
*/
4444
private $controllers = [];
4545

46-
public function __construct(string $translatorServiceId = 'translator', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_update', string $resolverServiceId = 'argument_resolver.service')
46+
public function __construct(string $translatorServiceId = 'translator', string $debugCommandServiceId = 'console.command.translation_debug', string $updateCommandServiceId = 'console.command.translation_extract', string $resolverServiceId = 'argument_resolver.service')
4747
{
4848
if (0 < \func_num_args()) {
4949
trigger_deprecation('symfony/translation', '5.3', 'Configuring "%s" is deprecated.', __CLASS__);

‎src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationPathsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/DependencyInjection/TranslationPathsPassTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testProcess()
3333
$debugCommand = $container->register('console.command.translation_debug')
3434
->setArguments([null, null, null, null, null, [], []])
3535
;
36-
$updateCommand = $container->register('console.command.translation_update')
36+
$updateCommand = $container->register('console.command.translation_extract')
3737
->setArguments([null, null, null, null, null, null, [], []])
3838
;
3939
$container->register(ControllerArguments::class, ControllerArguments::class)

‎src/Symfony/Component/Translation/Tests/DependencyInjection/TranslatorPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Tests/DependencyInjection/TranslatorPassTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function testValidCommandsViewPathsArgument()
6464
$debugCommand = $container->register('console.command.translation_debug')
6565
->setArguments([null, null, null, null, null, [], []])
6666
;
67-
$updateCommand = $container->register('console.command.translation_update')
67+
$updateCommand = $container->register('console.command.translation_extract')
6868
->setArguments([null, null, null, null, null, null, [], []])
6969
;
7070
$container->register('twig.template_iterator')
@@ -98,7 +98,7 @@ public function testCommandsViewPathsArgumentsAreIgnoredWithOldServiceDefinition
9898
null,
9999
])
100100
;
101-
$updateCommand = $container->register('console.command.translation_update')
101+
$updateCommand = $container->register('console.command.translation_extract')
102102
->setArguments([
103103
new Reference('translation.writer'),
104104
new Reference('translation.reader'),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.