Skip to content

Commit

Permalink
bug #35486 [Translator] Default value for 'sort' option in translatio…
Browse files Browse the repository at this point in the history
…n:update should be 'asc' (versgui)

This PR was squashed before being merged into the 4.4 branch (closes #35486).

Discussion
----------

[Translator] Default value for 'sort' option in translation:update should be 'asc'

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

The value for 'sort' option for `bin/console translation:update --sort` is optional, but no default value is defined. So the list isn't sorted if no value is explicitly defined.
This MR brings a default value "asc" if no value is defined, so the list is correctly sorted.

Commits
-------

fdb13c8 [Translator] Default value for 'sort' option in translation:update should be 'asc'
  • Loading branch information
fabpot committed Jan 30, 2020
2 parents 9803f3e + fdb13c8 commit 55df55e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -83,7 +83,7 @@ protected function configure()
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to update'),
new InputOption('xliff-version', null, InputOption::VALUE_OPTIONAL, 'Override the default xliff version', '1.2'),
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically'),
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically', 'asc'),
])
->setDescription('Updates the translation file')
->setHelp(<<<'EOF'
Expand Down
Expand Up @@ -48,6 +48,14 @@ public function testDumpReverseSortedMessagesAndClean()
$this->assertRegExp('/3 messages were successfully extracted/', $tester->getDisplay());
}

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

public function testDumpWrongSortAndClean()
{
$tester = $this->createCommandTester(['messages' => ['foo' => 'foo', 'test' => 'test', 'bar' => 'bar']]);
Expand Down

0 comments on commit 55df55e

Please sign in to comment.