Skip to content

Commit

Permalink
Use transchoice for error translation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Beaujean authored and javiereguiluz committed Sep 1, 2015
1 parent af4cf07 commit e823768
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
6 changes: 1 addition & 5 deletions Resources/translations/EasyAdminBundle.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@
<target>Add another item</target>
<trans-unit id="errors">
<source>errors</source>
<target>ERRORS</target>
</trans-unit>
<trans-unit id="error">
<source>error</source>
<target>ERROR</target>
<target>{1}ERROR|]1,Inf]ERRORS</target>
</trans-unit>
</body>
</file>
Expand Down
8 changes: 2 additions & 6 deletions Resources/translations/EasyAdminBundle.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,8 @@
<target>Ajouter un autre élément</target>
<trans-unit id="errors">
<source>errors</source>
<target>ERREURS</target>
</trans-unit>
<trans-unit id="error">
<source>error</source>
<target>ERREUR</target>
</trans-unit>
<target>{1}ERREUR|]1,Inf]ERREURS</target>
</trans-unit>
</body>
</file>
</xliff>
20 changes: 11 additions & 9 deletions Resources/views/form/bootstrap_3_layout.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,20 @@
{# Errors #}

{% block form_errors %}
{% if errors|length > 1 %}
{# Set it once to avoid using the filter multiple times #}
{% set errorCount = errors|length %}
{% if errorCount >= 1 %}
<div class="error-block">
<span class="label label-danger">{{ errors|length }} {{ 'errors'|trans }}</span>
<span class="label label-danger">{{ 'errors'|transchoice(errorCount) }}</span>
{% if errorCount > 1 %}
<ul>
{% for error in errors %}
<li>{{ error.message }}</li>
{% endfor %}
{% for error in errors %}
<li>{{ error.message }}</li>
{% endfor %}
</ul>
</div>
{% elseif errors|length == 1 %}
<div class="error-block">
<span class="label label-danger">{{ 'error'|trans }}</span> {{ errors|first.message }}
{% elseif errorCount == 1 %}
{{ errors|first.message }}
{% endif %}
</div>
{% endif %}
{% endblock form_errors %}

0 comments on commit e823768

Please sign in to comment.