10000 minor #15969 Updated the style of the translation commands (javieregu… · symfony/symfony@bee1faa · GitHub
[go: up one dir, main page]

Skip to content

Commit bee1faa

Browse files
committed
minor #15969 Updated the style of the translation commands (javiereguiluz)
This PR was squashed before being merged into the 2.8 branch (closes #15969). Discussion ---------- Updated the style of the translation commands | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - @ogizanagi did a great job updating the styles of these commands. This is just a bit of tweaking here and there: (Left = old; Right = new) ![comparison_1](https://cloud.githubusercontent.com/assets/73419/10136622/b2d049d2-65f5-11e5-9efe-ae74d546298d.png) ![comparison_2](https://cloud.githubusercontent.com/assets/73419/10136625/b8f96e24-65f5-11e5-8726-f092fc10ac38.png) ![comparison_3](https://cloud.githubusercontent.com/assets/73419/10136626/bb34a6cc-65f5-11e5-8312-0f084f04f0df.png) ![comparison_4](https://cloud.githubusercontent.com/assets/73419/10136630/bd851fd8-65f5-11e5-8ef0-71cce64fd2d7.png) ![comparison_5](https://cloud.githubusercontent.com/assets/73419/10136635/bf6173e2-65f5-11e5-9a25-8f04664cfe5a.png) Commits ------- 8bcb9fc Updated the style of the translation commands
2 parents 559554e + 8bcb9fc commit bee1faa

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
207207
private function formatState($state)
208208
{
209209
if (self::MESSAGE_MISSING === $state) {
210-
return '<error>missing</error>';
210+
return '<error> missing </error>';
211211
}
212212

213213
if (self::MESSAGE_UNUSED === $state) {
214-
return '<comment>unused</comment>';
214+
return '<comment> unused </comment>';
215215
}
216216

217217
if (self::MESSAGE_EQUALS_FALLBACK === $state) {
218-
return '<info>fallback</info>';
218+
return '<info> fallback </info>';
219219
}
220220

221221
return $state;
@@ -233,7 +233,7 @@ private function formatStates(array $states)
233233

234234
private function formatId($id)
235235
{
236-
return sprintf('<fg=cyan;options=bold>%s</fg=cyan;options=bold>', $id);
236+
return sprintf('<fg=cyan;options=bold>%s</>', $id);
237237
}
238238

239239
private function sanitizeString($string, $length = 40)

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

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
use Symfony\Component\Translation\MessageCatalogue;
2222

2323
/**
24-
* A command that parse templates to extract translation messages and add them into the translation files.
24+
* A command that parses templates to extract translation messages and adds them
25+
* into the translation files.
2526
*
2627
* @author Michel Salib <michelsalib@hotmail.com>
2728
*/
@@ -81,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8182
$writer = $this->getContainer()->get('translation.writer');
8283
$supportedFormats = $writer->getFormats();
8384
if (!in_array($input->getOption('output-format'), $supportedFormats)) {
84-
$output->error(array('Wrong output format', 'Supported formats are '.implode(', ', $supportedFormats).'.'));
85+
$output->error(array('Wrong output format', 'Supported formats are: '.implode(', ', $supportedFormat 10000 s).'.'));
8586

8687
return 1;
8788
}
@@ -111,12 +112,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
111112
}
112113
}
113114

114-
$output->title('Symfony translation update command');
115-
$output->text(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
115+
$output->title('Translation Messages Extractor and Dumper');
116+
$output->comment(sprintf('Generating "<info>%s</info>" translation files for "<info>%s</info>"', $input->getArgument('locale'), $currentName));
116117

117118
// load any messages from templates
118119
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
119-
$output->text('Parsing templates');
120+
$output->comment('Parsing templates...');
120121
$extractor = $this->getContainer()->get('translation.extractor');
121122
$extractor->setPrefix($input->getOption('prefix'));
122123
foreach ($transPaths as $path) {
@@ -128,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
128129

129130
// load any existing messages from the translation files
130131
$currentCatalogue = new MessageCatalogue($input->getArgument('locale'));
131-
$output->text('Loading translation files');
132+
$output->comment('Loading translation files...');
132133
$loader = $this->getContainer()->get('translation.loader');
133134
foreach ($transPaths as $path) {
134135
$path .= 'translations';
@@ -144,18 +145,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
144145

145146
// Exit if no messages found.
146147
if (!count($operation->getDomains())) {
147-
$output->warning('No translation found.');
148+
$output->warning('No translation messages were found.');
148149

149150
return;
150151
}
151152

152153
// show compiled list of messages
153-
if ($input->getOption('dump-messages') === true) {
154+
if (true === $input->getOption('dump-messages')) {
155+
$extractedMessagesCount = 0;
154156
$output->newLine();
155157
foreach ($operation->getDomains() as $domain) {
156-
$output->section(sprintf('Displaying messages for domain <info>%s</info>:', $domain));
157158
$newKeys = array_keys($operation->getNewMessages($domain));
158159
$allKeys = array_keys($operation->getMessages($domain));
160+
$domainMessagesCount = count($newKeys) + count($allKeys);
161+
162+
$output->section(sprintf('Messages extracted for domain "<info>%s</info>" (%d messages)', $domain, $domainMessagesCount));
163+
159164
$output->listing(array_merge(
160165
array_diff($allKeys, $newKeys),
161166
array_map(function ($id) {
@@ -165,11 +170,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
165170
return sprintf('<fg=red>%s</>', $id);
166171
}, array_keys($operation->getObsoleteMessages($domain)))
167172
));
173+
174+
$extractedMessagesCount += $domainMessagesCount;
168175
}
169176

170177
if ($input->getOption('output-format') == 'xlf') {
171-
$output->writeln('Xliff output version is <info>1.2</info>');
178+
$output->comment('Xliff output version is <info>1.2</info>');
172179
}
180+
181+
$resultMessage = sprintf('%d messages were successfully extracted', $extractedMessagesCount);
173182
}
174183

175184
if ($input->getOption('no-backup') === true) {
@@ -178,7 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
178187

179188
// save the files
180189
if ($input->getOption('force') === true) {
181-
$output->text('Writing files');
190+
$output->comment('Writing files...');
182191

183192
$bundleTransPath = false;
184193
foreach ($transPaths as $path) {
@@ -191,9 +200,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
191200
if ($bundleTransPath) {
192201
$writer->writeTranslations($operation->getResult(), $input->getOption('output-format'), array('path' => $bundleTransPath, 'default_locale' => $this->getContainer()->getParameter('kernel.default_locale')));
193202
}
203+
204+
if (true === $input->getOption('dump-messages')) {
205+
$resultMessage .= ' and translation files were updated.';
206+
} else {
207+
$resultMessage = 'Translation files were successfully updated.';
208+
}
194209
}
195210

196-
$output->newLine();
197-
$output->success('Success');
211+
$output->success($resultMessage);
198212
}
199213
}

0 commit comments

Comments
 (0)
0