Reputation: 2599
How can I translate labels values in Form builder.
Example:
->add('google_analytics_key', TextType::class, [
'label' => 'Analytics Key'
])
the "Analytics Key" is the value for the default locale.
I am using the form with rows:
{{ form_row(myForm.google_analytics_key) }}
This renders the label with input type as well, so I cannot use the trans
command.
Is there something built in Symfony/Twig or I must implement the form manually?
Upvotes: 0
Views: 2894
Reputation: 1630
This is for yml configuration.
First Check:
framework: translator: { fallbacks: [en] }
Then Inside translations folder: add your transalation file and add:::
test: Analytics Key
->add('google_analytics_key', TextType::class, [
'label' => 'test'
])
Upvotes: 1
Reputation: 2760
You can add the domain of your translation and the key
For example:
->add('google_analytics_key', TextType::class, [
'translation_domain' => '<your file name>',//for example 'messages'
'label' => 'app.analytics_key',
])
Upvotes: 2