Reputation: 544
I have some bundles in a Symfony2 project and I'm running the "translation:update" command to update the translation file for my bundle. While most of the parts works well and get the appropriate names, I don't seem to do the same for the form fields in the view files. Every time I run the command, I get back only the field name and not the full path I want them to have. For example e.g. I get fieldname instead of Mybyndle.formlabel.fieldname. I use the label option in the form builder in order for them to have the appropriate name as key and indeed the name changes when I see the form. But when I update the translation file, the entry in the file is only the field name.
What should I add to my code so that the translation sequence uses the correct format?
EDIT: This an example:
The two first lines are from some tables and have the correct names. The other three are the entity field names (?), because they are used as headers in the list and as form field labels in the "add new document" form.
What I want is to add a prefix name like "address.formlabel." in the entity fields.
Upvotes: 1
Views: 2640
Reputation: 546
translation:update wouldn't collect translation messages that used in PHP files(controller and forms).
Now, since Symfony 4.3 this feature is available, your comment is no longer relevant for new release. So you should prefer this official tool than JMS Translation.
The feature is here: https://github.com/symfony/symfony/pull/30120
The documentation: https://symfony.com/doc/current/translation.html#extracting-translation-contents-and-updating-catalogs-automatically
Upvotes: 0
Reputation: 1629
translation:update
wouldn't collect translation messages that used in PHP files(controller
and forms
).
I suggest to use jms translation, that can collect all translation messages from any place (forms
, controllers
, templates
, validations
)
Upvotes: 2