Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 494cfbd

Browse files
committed
Add option --as-tree to translation:update command
1 parent 2be6787 commit 494cfbd

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ CHANGELOG
1313
* added `framework.http_client.retry_failing` configuration tree
1414
* added `assertCheckboxChecked()` and `assertCheckboxNotChecked()` in `WebTestCase`
1515
* added `assertFormValue()` and `assertNoFormValue()` in `WebTestCase`
16+
* Added `--as-tree` option to `translation:update` command to dump messages as a tree-like structure.
1617

1718
5.1.0
1819
-----

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected function configure()
8484
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
8585
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
8686
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
87+
new InputOption('as-tree', null, InputOption::VALUE_NONE, 'Dump the messages as a tree-like structure'),
8788
])
8889
->setDescription('Updates the translation file')
8990
->setHelp(<<<'EOF'
@@ -302,7 +303,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
302303
$bundleTransPath = end($transPaths);
303304
}
304305

305-
$this->writer->write($operation->getResult(), $input->getOption('output-format'), ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale, 'xliff_version' => $input->getOption('xliff-version')]);
306+
$this->writer->write($operation->getResult(), $input->getOption('output-format'), ['path' => $bundleTransPath, 'default_locale' => $this->defaultLocale, 'xliff_version' => $input->getOption('xliff-version'), 'as_tree' => $input->getOption('as-tree')]);
306307

307308
if (true === $input->getOption('dump-messages')) {
308309
$resultMessage .= ' and translation files were updated';

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public function testDumpMessagesAndClean()
3232
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
3333
}
3434

35+
public function testDumpMessagesAsTreeAndClean()
36+
{
37+
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo']]);
38+
$tester->execute(['command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true, '--as-tree' => true]);
39+
$this->assertMatchesRegularExpression('/foo/', $tester->getDisplay());
40+
$this->assertMatchesRegularExpression('/1 message was successfully extracted/', $tester->getDisplay());
41+
}
42+
3543
public function testDumpSortedMessagesAndClean()
3644
{
3745
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);

0 commit comments

Comments
 (0)