Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] deprecate translation_parameters options given TranslatableMessage #42077

Copy link
Copy link
Open
@Tobion

Description

@Tobion
Issue body actions

Description
With the introduction of TranslatableMessage in #37670 (https://symfony.com/blog/new-in-symfony-5-2-translatable-objects) and being able to use this in form label and help in #41717, it makes all the translation_parameters options kind of obsolete and duplicates alot of functionality. So we should make sure that TranslatableMessage can be used in all relevant form options and then we should deprecate

The translation_domain option can likely be kept as it also serves as a way to disable translation and uses domain inheritance.

Example https://symfony.com/doc/current/reference/forms/types/choice.html#choice-translation-parameters

before:

$builder->add('id', null, [
    'choices' => [
        'form.order.yes' => true,
        'form.order.no' => false,
    ],
    'choice_translation_parameters' => function ($choice, $key, $value) {
        if (false === $choice) {
            return [];
        }

        return ['%company%' => 'ACME Inc.']
    },
]);

could be achieved with:

$builder->add('id', null, [
    'choices' => [
        'form.order.yes' => true,
        'form.order.no' => false,
    ],
    'choice_label' => function ($choice, $key, $value) {
        return new TranslatableMessage($key, false === $choice ? [] : ['%company%' => 'ACME Inc.']);
    },
]);

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.