8000 Fix translation:update command count · symfony/symfony@ffdd15e · GitHub
[go: up one dir, main page]

Skip to content

Commit ffdd15e

Browse files
committed
Fix translation:update command count
1 parent 69afe99 commit ffdd15e

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/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) {

src/Symfony/Bundle/FrameworkBundle/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)
0