-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Allow to define an empty prefix for translation:update command #20044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
translation:update
command
@javiereguiluz are you referring to this one? #19946, it's merged already 👍 |
@javiereguiluz I think it's still not working with empty string. Did you test it? |
@lordjancso Empty values for command options should be correctly handled since releases |
@chalasr I'm using 3.1.5 and its still not working. When I execute translation:update with --prefix="" its still not an empty string, because it passes NULL instead of empty string. And as far as I know, NULL is not an empty string. |
@lordjancso Yeah, this is the expected behavior (see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Input/ArgvInput.php#L224-L227). The issue is about that the option was not considered to be set at all, throwing an exception if the option requires a value. Now it converts any empty value into If you think it should not be converted (that I can perfectly understand), please open an issue/PR for proposing to change this. Please note that // argv.php
<?php
var_dump($argv); $ php argv.php --prefix=""
# array(2) {
# [0]=>
# string(18) "argv.php"
# [1]=>
# string(6) "--prefix="
# } |
@chalasr I see your point but this issue is about allowing to define empty string prefix for translation:update command and since it's still not working, I suggest to re-open it. |
@javiereguiluz The following example: $ ./bin/console translation:update en --dump-messages --prefix=""
# $prefix = '__'; <-- ERROR: I expected here an empty prefix Should be: $ ./bin/console translation:update en --dump-messages --prefix=""
# $prefix = null; <-- ERROR: I expected here an empty string Could you please update the description? |
@chalasr I was referring to the effective prefix used for translations instead of the value of the $prefix variable. But you are right and I've just updated the description to avoid confusion. Thanks! |
@javiereguiluz Yeah, sorry I forgot to precise it needs to be updated since #19946 only |
…n 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
…date (chalasr) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Add --no-prefix option to translation:update | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20044 | License | MIT | Doc PR | n/a This adds an option `--no-prefix` to the `translation:update` command, allowing to use an empty string as prefix. I guess it should be treated as a feature as it adds a new option to the command, but it indeed fixes the bug reported in #20044 (yeah, really this time). Commits ------- b5a1584 [FrameworkBundle] Add --no-prefix option to translation:update
…date (chalasr) This PR was merged into the 3.2-dev branch. Discussion ---------- [FrameworkBundle] Add --no-prefix option to translation:update | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#20044 | License | MIT | Doc PR | n/a This adds an option `--no-prefix` to the `translation:update` command, allowing to use an empty string as prefix. I guess it should be treated as a feature as it adds a new option to the command, but it indeed fixes the bug reported in #20044 (yeah, really this time). Commits ------- b5a1584 [FrameworkBundle] Add --no-prefix option to translation:update
Uh oh!
There was an error while loading. Please reload this page.
Context
When using the
translation:update
command to generate a translation file, the translated strings are just the original strings with the__
prefix (e.g. originalContact us
, "translation":__Contact us
). This value can be changed with the--prefix
option.Problem
When generating the translation file for the original language, I want to use an empty prefix. It seems impossible to do that because of the way Symfony Console options work:
I think in the past we had some issues reported for the way console options work, but I can't find the issues. Considering that setting an option with an empty value is the same as not setting that option looks confusing and it could even be considered a bug.
The text was updated successfully, but these errors were encountered: