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
TranslatableMessage not working in form #50744
Comments
Did you define the translations in the |
@xabbuh It's the same translation unit id which already exist in the demo. I did not tried to create a new translation file : "form.xlf", but i assume the system should use the proper domain. edit : my bad, i though the domain was "form" but in the demo, it's in "messages" and it's working now. I have the same issue (not translated) in my personal project. I will look deeper since it's working in the demo. Sorry for that. Thanks |
Finally after testing on demo project : ->add('title', null, [
'attr' => ['autofocus' => true],
'label' => new TranslatableMessage('label.title',[], 'messages'),
'data' => new TranslatableMessage('label.title',[], 'messages'),
]) The "data" display the value "label.title" instead of translation |
Can you create a small example application that allows to reproduce your issue? |
|
Hi @stof I can understand your point but it's a limiting the feature, no ? In my case : @xabbuh For the exemple, you can added in PostType of the demo symfony project : ->add('choice', EntityType::class, [
'label' => 'label.tags',
'choice_label' => function ($choice, $key, $value) {
return new TranslatableMessage('label.title',[], 'messages');
},
'class' => Post::class,
'mapped' => false,
'attr' =>
[
'data-placeholder' => new TranslatableMessage('label.title',[], 'messages')
]
]) "data-placeholder" does not display the translated value |
A TranslatableMessage still needs to be passed to the translator to actually produce a translated string. This class cannot magically get access to the translator to produce a translated string (btw, that's the reason why this class is not stringable). In your example, |
I did not know for the option "choice_translation_domain". Thanks :) I'm sorry i did not understand the first part of you answer. What class are you speaking about ? |
Hey, thanks for your report! |
Symfony version(s) affected
6.3.0
Description
Hi,
TranslatableMessage
seems not working in form option.Maybe i don't get some point but according to the documentaiton, i should be able to use the TranslatableMessage in form, no ?
How to reproduce
I took, the Symfony demo project 2.2.3
Then, i replaced the field "title" in the
PostType.php
fileThe title is not translated.
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: