Skip to content

Commit

Permalink
added missing translator calls in form templates
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Jun 29, 2011
1 parent ed4de1f commit 339ad86
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
Expand Up @@ -19,7 +19,7 @@
{% spaceless %}
{% for choice, label in options %}
{% if _form_is_choice_group(label) %}
<optgroup label="{{ choice }}">
<optgroup label="{{ choice|trans }}">
{% for nestedChoice, nestedLabel in label %}
<option value="{{ nestedChoice }}"{% if _form_is_choice_selected(form, nestedChoice) %} selected="selected"{% endif %}>{{ nestedLabel|trans }}</option>
{% endfor %}
Expand Down
@@ -1,11 +1,11 @@
<?php foreach ($options as $choice => $label): ?>
<?php if ($view['form']->isChoiceGroup($label)): ?>
<optgroup label="<?php echo $view->escape($choice) ?>">
<optgroup label="<?php echo $view->escape($view['translator']->trans($choice)) ?>">
<?php foreach ($label as $nestedChoice => $nestedLabel): ?>
<option value="<?php echo $view->escape($nestedChoice) ?>"<?php if ($view['form']->isChoiceSelected($form, $nestedChoice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($nestedLabel) ?></option>
<option value="<?php echo $view->escape($nestedChoice) ?>"<?php if ($view['form']->isChoiceSelected($form, $nestedChoice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($nestedLabel)) ?></option>
<?php endforeach ?>
</optgroup>
<?php else: ?>
<option value="<?php echo $view->escape($choice) ?>"<?php if ($view['form']->isChoiceSelected($form, $choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($label) ?></option>
<option value="<?php echo $view->escape($choice) ?>"<?php if ($view['form']->isChoiceSelected($form, $choice)): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($label)) ?></option>
<?php endif ?>
<?php endforeach ?>
62 changes: 31 additions & 31 deletions tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php
Expand Up @@ -334,8 +334,8 @@ public function testSingleChoice()
[@name="na&me"]
[@required="required"]
[
./option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=2]
'
Expand All @@ -357,9 +357,9 @@ public function testSingleChoiceWithPreferred()
[@name="na&me"]
[@required="required"]
[
./option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
/following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"]
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -382,8 +382,8 @@ public function testSingleChoiceNonRequired()
[not(@required)]
[
./option[@value=""][.="[trans][/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -406,8 +406,8 @@ public function testSingleChoiceNonRequiredNoneSelected()
[not(@required)]
[
./option[@value=""][.="[trans][/trans]"]
/following-sibling::option[@value="&a"][not(@selected)][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
/following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -431,8 +431,8 @@ public function testSingleChoiceWithNonRequiredEmptyValue()
[not(@required)]
[
./option[@value=""][not(@selected)][.="[trans]Select&Anything&Not&Me[/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -456,8 +456,8 @@ public function testSingleChoiceRequiredWithEmptyValue()
[@required="required"]
[
./option[@value=""][.="[trans]Test&Me[/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -480,8 +480,8 @@ public function testSingleChoiceRequiredWithEmptyValueViaView()
[@required="required"]
[
./option[@value=""][.="[trans][/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=3]
'
Expand All @@ -503,15 +503,15 @@ public function testSingleChoiceGrouped()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="na&me"]
[./optgroup[@label="Group&1"]
[./optgroup[@label="[trans]Group&1[/trans]"]
[
./option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=2]
]
[./optgroup[@label="Group&2"]
[./option[@value="&c"][not(@selected)][.="Choice&C"]]
[./optgroup[@label="[trans]Group&2[/trans]"]
[./option[@value="&c"][not(@selected)][.="[trans]Choice&C[/trans]"]]
[count(./option)=1]
]
[count(./optgroup)=2]
Expand All @@ -533,8 +533,8 @@ public function testMultipleChoice()
[@name="na&me[]"]
[@multiple="multiple"]
[
./option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=2]
'
Expand All @@ -556,8 +556,8 @@ public function testMultipleChoiceSkipEmptyValue()
[@name="na&me[]"]
[@multiple="multiple"]
[
./option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=2]
'
Expand All @@ -579,8 +579,8 @@ public function testMultipleChoiceNonRequired()
[@name="na&me[]"]
[@multiple="multiple"]
[
./option[@value="&a"][@selected="selected"][.="Choice&A"]
/following-sibling::option[@value="&b"][not(@selected)][.="Choice&B"]
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
[count(./option)=2]
'
Expand Down Expand Up @@ -688,7 +688,7 @@ public function testCountry()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="na&me"]
[./option[@value="AT"][@selected="selected"][.="Austria"]]
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
[count(./option)>200]
'
);
Expand All @@ -706,7 +706,7 @@ public function testCountryWithEmptyValue()
'/select
[@name="na&me"]
[./option[@value=""][not(@selected)][.="[trans]Select&Country[/trans]"]]
[./option[@value="AT"][@selected="selected"][.="Austria"]]
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
[count(./option)>201]
'
);
Expand Down Expand Up @@ -1226,7 +1226,7 @@ public function testLanguage()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="na&me"]
[./option[@value="de"][@selected="selected"][.="German"]]
[./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]]
[count(./option)>200]
'
);
Expand All @@ -1241,7 +1241,7 @@ public function testLocale()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="na&me"]
[./option[@value="de_AT"][@selected="selected"][.="German (Austria)"]]
[./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]]
[count(./option)>200]
'
);
Expand Down Expand Up @@ -1592,8 +1592,8 @@ public function testTimezone()
[@name="na&me"]
[@required="required"]
[./optgroup
[@label="Europe"]
[./option[@value="Europe/Vienna"][@selected="selected"][.="Vienna"]]
[@label="[trans]Europe[/trans]"]
[./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]]
]
[count(./optgroup)>10]
[count(.//option)>200]
Expand Down

0 comments on commit 339ad86

Please sign in to comment.