8000 [Form][choice] disable translate choices for Intl and Timezone form t… · symfony/symfony@7904f74 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7904f74

Browse files
committed
[Form][choice] disable translate choices for Intl and Timezone form types.
1 parent bc194c5 commit 7904f74

File tree

8 files changed

+12
-7
lines changed

8 files changed

+12
-7
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
{{- block('choice_widget_options') -}}
8080
</optgroup>
8181
{%- else -%}
82-
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translate_choices is sameas(false) ? choice.label : choice.label|trans({}, translation_domain) }}</option>
82+
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ translate_choices ? choice.label|trans({}, translation_domain) : choice.label }}</option>
8383
{%- endif -%}
8484
{% endfor %}
8585
{%- endblock choice_widget_options -%}

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CHANGELOG
44
2.7.0
55
-----
66

7-
* added options "translate_choices" to ChoiceType.
7+
* added option "translate_choices" to ChoiceType.
88
* deprecated the overwriting of AbstractType::setDefaultOptions() in favor of overwriting AbstractType::configureOptions().
99
* deprecated the overwriting of AbstractTypeExtension::setDefaultOptions() in favor of overwriting AbstractTypeExtension::configureOptions().
1010

src/Symfony/Component/Form/Extension/Core/Type/CountryType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getRegionBundle()->getCountryNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getCurrencyBundle()->getCurrencyNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/LanguageType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getLanguageBundle()->getLanguageNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/LocaleType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function configureOptions(OptionsResolver $resolver)
2424
{
2525
$resolver->setDefaults(array(
2626
'choices' => Intl::getLocaleBundle()->getLocaleNames(),
27+
'translate_choices' => false,
2728
));
2829
}
2930

src/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function configureOptions(OptionsResolver $resolver)
3030
{
3131
$resolver->setDefaults(array(
3232
'choices' => self::getTimezones(),
33+
'translate_choices' => false,
3334
));
3435
}
3536

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ public function testCountry()
909909
$this->assertWidgetMatchesXpath($form->createView(), array(),
910910
'/select
911911
[@name="name"]
912-
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
912+
[./option[@value="AT"][@selected="selected"][.="Austria"]]
913913
[count(./option)>200]
914914
'
915915
);
@@ -926,7 +926,7 @@ public function testCountryWithPlaceholder()
926926
'/select
927927
[@name="name"]
928928
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]]
929-
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
929+
[./option[@value="AT"][@selected="selected"][.="Austria"]]
930930
[count(./option)>201]
931931
'
932932
);
@@ -1450,7 +1450,7 @@ public function testLanguage()
14501450
$this->assertWidgetMatchesXpath($form->createView(), array(),
14511451
'/select
14521452
[@name="name"]
1453-
[./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]]
1453+
[./option[@value="de"][@selected="selected"][.="German"]]
14541454
[count(./option)>200]
14551455
'
14561456
);
@@ -1463,7 +1463,7 @@ public function testLocale()
14631463
$this->assertWidgetMatchesXpath($form->createView(), array(),
14641464
'/select
14651465
[@name="name"]
1466-
[./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]]
1466+
[./option[@value="de_AT"][@selected="selected"][.="German (Austria)"]]
14671467
[count(./option)>200]
14681468
'
14691469
);
@@ -1830,7 +1830,7 @@ public function testTimezone()
18301830
[not(@required)]
18311831
[./optgroup
18321832
[@label="[trans]Europe[/trans]"]
1833-
[./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]]
1833+
[./option[@value="Europe/Vienna"][@selected="selected"][.="Vienna"]]
18341834
]
18351835
[count(./optgroup)>10]
18361836
[count(.//option)>200]

0 commit comments

Comments
 (0)
0