Skip to content

Commit d7a9bb9

Browse files
committed
Merge branch '2.8' into 3.1
* 2.8: [travis/appveyor] Wire simple-phpunit [Console] fixed PHP7 Errors are now handled and converted to Exceptions Fix #19721 Fix translation:update command count bumped Symfony version to 2.8.12 updated VERSION for 2.8.11 updated CHANGELOG for 2.8.11 bumped Symfony version to 2.7.19 updated VERSION for 2.7.18 update CONTRIBUTORS for 2.7.18 updated CHANGELOG for 2.7.18 [Security] Optimize RoleHierarchy's buildRoleMap method
2 parents 59d8e4f + 18e6287 commit d7a9bb9

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Command/TranslationUpdateCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,21 @@ protected function execute(InputInterface $input, OutputInterface $output)
160160
foreach ($operation->getDomains() as $domain) {
161161
$newKeys = array_keys($operation->getNewMessages($domain));
162162
$allKeys = array_keys($operation->getMessages($domain));
163-
$domainMessagesCount = count($newKeys) + count($allKeys);
164163

165-
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d messages)', $domain, $domainMessagesCount));
166-
167-
$io->listing(array_merge(
164+
$list = array_merge(
168165
array_diff($allKeys, $newKeys),
169166
array_map(function ($id) {
170167
return sprintf('<fg=green>%s</>', $id);
171168
}, $newKeys),
172169
array_map(function ($id) {
173170
return sprintf('<fg=red>%s</>', $id);
174171
}, array_keys($operation->getObsoleteMessages($domain)))
175-
));
172+
);
173+
174+
$domainMessagesCount = count($list);
175+
176+
$io->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d message%s)', $domain, $domainMessagesCount, $domainMessagesCount > 1 ? 's' : ''));
177+
$io->listing($list);
176178

177179
$extractedMessagesCount += $domainMessagesCount;
178180
}
@@ -181,7 +183,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
181183
$io->comment('Xliff output version is <info>1.2</info>');
182184
}
183185

184-
$resultMessage = sprintf('%d messages were successfully extracted', $extractedMessagesCount);
186+
$resultMessage = sprintf('%d message%s successfully extracted', $extractedMessagesCount, $extractedMessagesCount > 1 ? 's were' : ' was');
185187
}
186188

187189
if ($input->getOption('no-backup') === true) {

Tests/Command/TranslationUpdateCommandTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ public function testDumpMessagesAndClean()
2828
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo')));
2929
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
3030
$this->assertRegExp('/foo/', $tester->getDisplay());
31+
$this->assertRegExp('/1 message was successfully extracted/', $tester->getDisplay());
32+
}
33+
34+
public function testDumpTwoMessagesAndClean()
35+
{
36+
$tester = $this->createCommandTester($this->getContainer(array('foo' => 'foo', 'bar' => 'bar')));
37+
$tester->execute(array('command' => 'translation:update', 'locale' => 'en', 'bundle' => 'foo', '--dump-messages' => true, '--clean' => true));
38+
$this->assertRegExp('/foo/', $tester->getDisplay());
39+
$this->assertRegExp('/bar/', $tester->getDisplay());
3140
$this->assertRegExp('/2 messages were successfully extracted/', $tester->getDisplay());
3241
}
3342

0 commit comments

Comments
 (0)