Skip to content
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

[2.7][Form][choice] add doc about the new option: choice_translation_domain #5134

Closed
aitboudad opened this issue Apr 2, 2015 · 17 comments
Closed
Labels
actionable Clear and specific issues ready for anyone to take them. Form hasPR A Pull Request has already been submitted for this issue.
Milestone

Comments

@aitboudad
Copy link
Contributor

symfony/symfony#13651

choice_translation_domain (bool | null | string)

  • true: reuse current translation_domain
  • false: disabled
  • null: parents translation_domain or default domain (messages)
  • string: explicit domain
@Tobion
Copy link
Contributor

Tobion commented Apr 2, 2015

It's choice_translation_domain (bool | null | string)

@xabbuh xabbuh added this to the 2.7 milestone Apr 3, 2015
@wouterj
Copy link
Member

wouterj commented May 10, 2015

This has to be documented in the form type reference using the same format as the other options and should also have a .. versionadded:: 2.7 directive indicating that this option was introduced in Symfony 2.7.

@wouterj wouterj added good first issue Ideal for your first contribution! (some Symfony experience may be required) actionable Clear and specific issues ready for anyone to take them. and removed good first issue Ideal for your first contribution! (some Symfony experience may be required) labels May 10, 2015
@nothingaa
Copy link

Is there a way to impact the whole entity in a single call?
I have tried to call the following funciton and it is not working.

public function configureOptions(OptionsResolver $resolver)
{
    $resolver->setDefaults(array(
        'choice_translation_domain' => true,
    ));
}

@ricohumme
Copy link

On what form field types is the choice_translation_domain effective?
I'm testing with field type date and it throws an error saying it's a non-existent option.
As for the docs, it has no reference yet on the use of this options.

Could some clarify?

Edit:
When using translation_domain => false on the date type, it does work.
Am I just interpreting the choice_translation_domain wrong?

Edit 2:
When using this as in the mention above, the label is also no longer translated. I assumed it was just having effect on the choice widget?

@xabbuh
Copy link
Member

xabbuh commented Aug 17, 2015

@aitboudad Can you confirm that what @ricohumme describes is the intended behaviour?

@xabbuh xabbuh added the hasPR A Pull Request has already been submitted for this issue. label Aug 17, 2015
@xabbuh
Copy link
Member

xabbuh commented Aug 17, 2015

By the way, there is an open pull request: see #5614

@aitboudad
Copy link
Contributor Author

Sorry I don't have much time these days ^^ below how it work:
The choice_translation_domain is related to translation_domain only when the value is equal to true or null, it was introduced to enable/disable translation for optgroup and option in Choice Fields:

  • Default value: true
    • choice
  • Default value: false
    • country
    • currency
    • language
    • locale
    • timezone
    • entity

for the date type currently it's not possible but it can be introduced in 2.8 once symfony/symfony#15301 got merged.

@aitboudad
Copy link
Contributor Author

@ricohumme not sure if I understood the Edit 2: can you leave us an example to reproduce it.

@ricohumme
Copy link

Sure!
When using the following code:

$builder->add('purchaseDate', 'date', [
            'label' => 'rma_form.label.purchaseDate',
            'placeholder' => array('year' => 'Year', 'month' => 'Month', 'day' => 'Day'),
            'widget' => 'choice',
            'required' => true,
            'translation_domain' => false
        ]);

The output on the screen renders the widgets without translating the contents of the widgets, however the label also shows rma_form.label.purchaseDate (not translated)

When using the following code:

$builder->add('purchaseDate', 'date', [
            'label' => 'rma_form.label.purchaseDate',
            'placeholder' => array('year' => 'label.year', 'month' => 'label.month', 'day' => 'label.day'),
            'widget' => 'choice',
            'required' => true
        ]);

The output on the screen renders the widgets and translates the content: So the placeholders are correct, but also the numbers are translated. The label widget label is correctly translated.

@aitboudad
Copy link
Contributor Author

@ricohumme your example work as expected :), as I already mentioned above the choice_translation_domain doesn't affect the date type.

@ricohumme
Copy link

@aitboudad that is true, you did. But do you agree that the date type should work the same way the choice type does when it comes to choice_translation_domain ?

@aitboudad
Copy link
Contributor Author

@ricohumme yes, see symfony/symfony#15301

@xabbuh
Copy link
Member

xabbuh commented Aug 22, 2015

@ricohumme @aitboudad What about the label not being translated? Is that intended too?

@aitboudad
Copy link
Contributor Author

@xabbuh when translation_domain = false the label is not translated see:

{{ translation_domain is sameas(false) ? label : label|trans({}, translation_domain) }}

@xabbuh
Copy link
Member

xabbuh commented Aug 22, 2015

@aitboudad Yes, but was that really intended?

@aitboudad
Copy link
Contributor Author

@xabbuh not sure, anyway not related to this issue !

@peterrehm
Copy link
Contributor

Fixed by #5906

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. Form hasPR A Pull Request has already been submitted for this issue.
Projects
None yet
Development

No branches or pull requests

7 participants