-
Notifications
You must be signed in to change notification settings - Fork 293
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
Translator chokes on numerical IDs #83
Comments
Just ran afoul of this. |
happend to me when I was translating true (evaluated to 1) of some variable (not string). I am using my twig variable extractor. Code in below caused this error. views/Others/deathCalc.html.twig/jms:reference-file |
Thank you for reporting this. This issue is very old, do you have the same problem with the latest release? |
Unfortunately we are still running an old version so I have no easy way of reproducing this. Sorry! |
Okey. |
I reproduced it, even with the newest version. The strange thing is that "/** Ignore */" tag has no effect on it. I "fixed" the problem by adding quotes to the integer value. |
Fixed by #384 |
The translator / extractor chokes on numerical IDs. The steps to replicate this are quite simple:
Have a file that has a numerical translation key, ie. in a Twig template:
{{ 1 | trans }}
Run the
translation:extract
command with--output-format=yml
In the messages file a new line like
1: '1' # FIXME
will be added...everything fine so far
Now run the extraction again, and this time the command will throw an exception:
[JMS\TranslationBundle\Exception\RuntimeException]
You can only merge messages with the same id. Expected id "1", but got "1".
While translating numbers seems quite silly, the problem is that the whole extraction process goes awry.
The issue is caused by this part in
Model/Message.php
:The extracted message's ID (
$this->id
) is aString
, while the existing message's ID ($message->getId()
) is anint
. Now, the obvious fix would be just use!=
to compare, but this may very well have other implications.The text was updated successfully, but these errors were encountered: