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
This commit is contained in:
commit
3f650f864c
@ -118,8 +118,9 @@ EOF
|
|||||||
// load any messages from templates
|
// load any messages from templates
|
||||||
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
$extractedCatalogue = new MessageCatalogue($input->getArgument('locale'));
|
||||||
$output->text('Parsing templates');
|
$output->text('Parsing templates');
|
||||||
|
$prefix = $input->getOption('prefix');
|
||||||
$extractor = $this->getContainer()->get('translation.extractor');
|
$extractor = $this->getContainer()->get('translation.extractor');
|
||||||
$extractor->setPrefix($input->getOption('prefix'));
|
$extractor->setPrefix(null === $prefix ? '' : $prefix);
|
||||||
foreach ($transPaths as $path) {
|
foreach ($transPaths as $path) {
|
||||||
$path .= 'views';
|
$path .= 'views';
|
||||||
if (is_dir($path)) {
|
if (is_dir($path)) {
|
||||||
|
Reference in New Issue
Block a user