8000 Form labels force translation language · Issue #23611 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Form labels force translation language #23611
Closed
@ghost

Description

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version all

I have a situation where I have set a locale for my application but there is a form in a different language where I want to have the labels available in that language.

inside the vendor\symfony\Symfony\src\Symfony\Bridge\Twig\Resources\views\Form\form_div_layout.html.twig we have block form_label. This block accepts translation key and the domain but no language

`label : label|trans({}, translation_domain)`.

In a normal situation I would use something like this in order to force the language:

{{ translation.key | trans({}, 'messages', 'de') }}

In the form builder now we can do something like:

$builder
    ->add('field', TextType::class, [
        'label' => 'translation.key',
        'translation_domain' => 'messages',

Would be of any use to add something like:

$builder
    ->add('field', TextType::class, [
        'label' => 'translation.key',
        'translation_domain' => 'messages',
        'translation_domain_language' => 'de' //as language iso or whatever that can be passed from controller or other places

and to end up using inside the block form_label something like:

`label : label|trans({}, translation_domain, translation_domain_language)`.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0