Skip to content

Commit 0430e78

Browse files
committed
bug #20184 [FrameworkBundle] Convert null prefix to an empty string in translation:update (chalasr)
This PR was merged into the 2.7 branch. Discussion ---------- [FrameworkBundle] Convert null prefix to an empty string in translation:update | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20044 | License | MIT | Doc PR | n/a This command needs the ability to use an empty string as prefix, which is not possible using `bin/console translation:update --prefix=""` because `$argv` doesn't parse empty strings thus the value is converted to `null` by `ArgvInput` (only since #19946, before the option was not considered to be set, giving the default `'__'` thus this should be fine from a BC pov). Here I propose to explicitly convert the `prefix` value to an empty string if set to `null`, as it is a very specific need and we can't guess that from `ArgvInput`. An other way to fix it could be to add a `--no-prefix` option to the command but I don't think it is worth it, and it couldn't be treated as a bug fix thus not fixed before `3.2`. Commits ------- f02b687 [FrameworkBundle] Convert null prefix to an empty string in translation:update command
2 parents 613ac94 + e2bcbc9 commit 0430e78

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Command/TranslationUpdateCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
118118
// load any messages from templates
119119
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
120120
$output->text('Parsing templates');
121+
$prefix = $input->getOption('prefix');
121122
$extractor = $this->getContainer()->get('translation.extractor');
122-
$extractor->setPrefix($input->getOption('prefix'));
123+
$extractor->setPrefix(null === $prefix ? '' : $prefix);
123124
foreach ($transPaths as $path) {
124125
$path .= 'views';
125126
if (is_dir($path)) {

0 commit comments

Comments
 (0)