Skip to content

Commit

Permalink
Translated boolean labels when using "toggle" fields
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Sep 9, 2015
1 parent 62329ce commit 8866b28
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
18 changes: 10 additions & 8 deletions Resources/translations/EasyAdminBundle.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@
<target><![CDATA[<strong>%start%</strong> - <strong>%end%</strong> of <strong>%results%</strong>]]></target>
</trans-unit>

<!-- labels -->
<trans-unit id="label.true">
<source>label.true</source>
<target>Yes</target>
</trans-unit>
<trans-unit id="label.false">
<source>label.false</source>
<target>No</target>
</trans-unit>

<!-- misc. elements -->
<trans-unit id="header.close">
<source>header.close</source>
Expand Down Expand Up @@ -121,14 +131,6 @@
<source>errors</source>
<target>Error|Errors</target>
</trans-unit>
<trans-unit id="boolean.true">
<source>boolean.true</source>
<target>Yes</target>
</trans-unit>
<trans-unit id="boolean.false">
<source>boolean.false</source>
<target>No</target>
</trans-unit>
</body>
</file>
</xliff>
18 changes: 10 additions & 8 deletions Resources/translations/EasyAdminBundle.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@
<target><![CDATA[<strong>%start%</strong> - <strong>%end%</strong> sur <strong>%results%</strong>]]></target>
</trans-unit>

<!-- labels -->
<trans-unit id="label.true">
<source>label.true</source>
<target>Oui</target>
</trans-unit>
<trans-unit id="label.false">
<source>label.false</source>
<target>Non</target>
</trans-unit>

<!-- misc. elements -->
<trans-unit id="header.close">
<source>header.close</source>
Expand Down Expand Up @@ -121,14 +131,6 @@
<source>errors</source>
<target>Erreur|Erreurs</target>
</trans-unit>
<trans-unit id="boolean.true">
<source>boolean.true</source>
<target>Oui</target>
</trans-unit>
<trans-unit id="boolean.false">
<source>boolean.false</source>
<target>Non</target>
</trans-unit>
</body>
</file>
</xliff>
15 changes: 14 additions & 1 deletion Resources/views/css/admin.css.twig
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ div.flash-error strong {
}
.label {
color: {{ colors.white }};
display: inline-block;
font-size: 11px;
padding: 2px 4px;
padding: 4px;
text-transform: uppercase;
}
.label-success {
Expand All @@ -201,12 +202,19 @@ div.flash-error strong {
color: {{ colors.text }};
}

/* this makes boolean labels to be of the same width for most languages */
.boolean .label,
.toggle .label {
min-width: 33px;
}

/* Switches / toggles
------------------------------------------------------------------------- */
.toggle .btn {
border-radius: 3px;
font-size: 11px;
font-weight: bold;
text-transform: uppercase;
}
.toggle .toggle.btn-success {
border-color: {{ colors.success }};
Expand Down Expand Up @@ -239,6 +247,11 @@ div.flash-error strong {
margin-top: 1px;
margin-right: 5px;
}
.toggle .toggle-on.btn-xs,
.toggle .toggle-off.btn-xs {
padding-left: 4px;
text-align: center;
}

/* Badges
------------------------------------------------------------------------- */
Expand Down
7 changes: 4 additions & 3 deletions Resources/views/default/field_boolean.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% trans_default_domain "EasyAdminBundle" %}

{% if value == true %}
<span class="label label-success">{{ 'boolean.true'|trans }}</span>
<span class="label label-success">{{ 'label.true'|trans }}</span>
{% else %}
<span class="label label-danger">{{ 'boolean.false'|trans }}</span>
{% endif %}
<span class="label label-danger">{{ 'label.false'|trans }}</span>
{% endif %}
10 changes: 8 additions & 2 deletions Resources/views/default/field_toggle.html.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{% trans_default_domain "EasyAdminBundle" %}

{% if view == 'show' %}
<span class="label label-{{ value == true ? 'success' : 'danger' }}">{{ value == true ? 'YES' : 'NO' }}</span>
{% if value == true %}
<span class="label label-success">{{ 'label.true'|trans }}</span>
{% else %}
<span class="label label-danger">{{ 'label.false'|trans }}</span>
{% endif %}
{% else %}
<input type="checkbox" {{ value == true ? 'checked' : '' }}
data-toggle="toggle" data-size="mini"
data-onstyle="success" data-offstyle="danger"
data-on="YES" data-off="NO">
data-on="{{ 'label.true'|trans }}" data-off="{{ 'label.false'|trans }}">
{% endif %}

0 comments on commit 8866b28

Please sign in to comment.