Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

[Form] Add translation_parameters option to base form type#27775

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
webnet-fr wants to merge6 commits intosymfony:masterfromwebnet-fr:form_translation_parameters
Closed

[Form] Add translation_parameters option to base form type#27775

webnet-fr wants to merge6 commits intosymfony:masterfromwebnet-fr:form_translation_parameters

Conversation

@webnet-fr
Copy link
Contributor

@webnet-frwebnet-fr commentedJun 29, 2018
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes. Travis-ci isn't green because it tests the components separately. Fabbot.io requires license headers in files where they were not present before.
Fixed tickets#27698
LicenseMIT
Doc PRsymfony/symfony-docs/pull/10065

In forms it would be very nice if there is a way to provide translation parameters forlabel andhelp optons. Consider this example :

#messages.en.ymlform:order_list:id:Identifier of the order to %company%first:First position is to send to %address%second:Second position is to send to %address%second_help:This must be %item%
#messages.fr.ymlform:order_list:id:Identifiant de la commande pour la société %company%first:Première position est à envoyer à %address%second:Seconde position est à envoyer à %address%second_help:Ce doit être %item%
class OrderListTypeextends AbstractType{publicfunctionbuildForm(FormBuilderInterface$builder,array$options)    {$builder            ->add('id', TextType::class, ['label' =>'form.order_list.id','translation_parameters' => ['%company%' =>'Webnet'                ]            ])            ->add('list', FormType::class, ['translation_parameters' => ['%address%' =>'Sèvres, 92310'                ]            ])        ;// Add list's children to demonstrate translation_parameters inheritance.$builder->get('list')            ->add('first', TextType::class, ['label' =>'form.order_list.first','translation_parameters' => [// "Paris, 75010" (a value particular to this field) will overwrite "Sèvres, 92310"'%address%' =>'Paris, 75010'                 ]            ])            ->add('second', TextType::class, ['label' =>'form.order_list.second','help' =>'form.order_list.second_help','translation_parameters' => [// Inherit %address% from parent => 'Sèvres, 92310',// "item" parameter is used in help message.'%item%' =>'DIN5555'                ],            ])        ;    }}

Here is a result with translation parameters :
With parameters

and without them :
With parameters

yceruto reacted with thumbs up emoji
@webnet-frwebnet-fr changed the titleAdd translation_parameters option to base form type[Form] Add translation_parameters option to base form typeJun 29, 2018
@nicolas-grekasnicolas-grekas added this to thenext milestoneJun 29, 2018
@xabbuh
Copy link
Member

Having just onetranslation_parameters option could lead to hard to solve issues if you want to pass parameters with the same name to the translations for the label and the help string but with actually different values. IMO if we were to add this, we would need two distinct options.

@webnet-fr
Copy link
ContributorAuthor

@xabbuh that's a good point but I'd rather limit the proliferation of options. There is a very little chance that there would be the same translation parameter inlabel and inhelp that would require different values. In such cases I suggest to use slightly different translation parameters to reflect the difference in values (like%company% inlabel and%company_vat% inhelp).
Cheers.

@webnet-fr
Copy link
ContributorAuthor

Translation parameters were injected to labels and helps. Tests were added.

Should we inject translation parameters into buttons, attributes and choice options as well? It would be nice, isn’t it?

As for the comment of@xabbuh I would suggest a singletranslation_parameters for labels, helps, buttons and attributes because they share the sametranslation_domain. And we can addchoice_translation_ parameters for choices because they have a separatechoice_translation_domain.

yceruto reacted with thumbs up emoji

@xabbuh
Copy link
Member

I still think that different parameters for label and help is the way to go. The message id that is passed to the translator is already different (i.e. the label or the help message) and so we should separate the parameters.

Apart from that I like this feature.

@xabbuh
Copy link
Member

Thanks for opening#28635. I think we can close here in favour of your other PR.

@xabbuhxabbuh closed thisOct 1, 2018
@nicolas-grekasnicolas-grekas modified the milestones:next,4.2Nov 1, 2018
fabpot added a commit that referenced this pull requestFeb 13, 2019
…ion_parameters and attr_translation_parameters options to base form type (webnet-fr)This PR was squashed before being merged into the 4.3-dev branch (closes#28635).Discussion----------[Form] Add label_translation_parameters, help_translation_parameters and attr_translation_parameters options to base form type| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes. Travis-ci isn't green because it tests the components separately. Fabbot.io requires license headers in files where they were not present before.| Fixed tickets |#27698| License       | MIT| Doc PR        |symfony/symfony-docs#10065Hi, this is an alternative to#27775.`translation_parameters` is separated to `label_translation_parameters`, `help_translation_parameters`, `attr_translation_parameters`.Commits-------b3f3c53 [Form] Add label_translation_parameters, help_translation_parameters and attr_translation_parameters options to base form type
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

4.2

Development

Successfully merging this pull request may close these issues.

4 participants

@webnet-fr@xabbuh@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp