Skip to content

Commit 61cf8b5

Browse files
committed
Update form_admin_fields.html.twig for translation domain usage
Adjusted 'form_admin_fields.html.twig' for considering admin's translation domain if 'admin' object is present. Modifications have also been made to replace hard-coded text classes with translatable strings. These changes result in wider localization support and more flexible design.
1 parent 518d549 commit 61cf8b5

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/Resources/views/Form/form_admin_fields.html.twig

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file is part of the Networking package.
66
For the full copyright and license information, please view the LICENSE
77
file that was distributed with this source code.
88
#}
9-
{% extends 'bootstrap_5_layout.html.twig' %}
9+
{% use 'bootstrap_5_layout.html.twig' %}
1010

1111
{# Custom Sonata Admin Extension, template override #}
1212
{% block sonata_admin_orm_one_to_one_widget %}
@@ -153,6 +153,10 @@ file that was distributed with this source code.
153153

154154
{% block form_label %}
155155
{{ parent() }}
156+
157+
{% if admin %}
158+
{% set translation_domain = admin.translationDomain %}
159+
{% endif %}
156160
{% if help_label %}
157161
{{ block('help_label') }}
158162
{% endif %}
@@ -165,18 +169,18 @@ file that was distributed with this source code.
165169
{% endblock form_label %}
166170

167171
{% block help_label %}
168-
<span class="help-block">{{ help_label|trans({}, translation_domain) }}</span>
172+
<span class="help-block form-text">{{ help_label|trans(help_translation_parameters, translation_domain) }}</span>
169173
{% endblock help_label %}
170174

171175
{% block help_label_tooltip %}
172-
<span class="help-block">
176+
<span class="help-block form-text">
173177
<a href="#" data-bs-toggle="tooltip" data-bs-placement="{{ help_label_tooltip.placement }}"
174-
title="{{ help_label_tooltip.title|trans({}, translation_domain) }}">
178+
title="{{ help_label_tooltip.title|trans(help_translation_parameters, translation_domain) }}">
175179
{% if help_label_tooltip.icon is not same as(false) %}
176180
{{ networking_bootstrap_icon(help_label_tooltip.icon) }}
177181
{% endif %}
178182
{% if help_label_tooltip.text is not same as(null) %}
179-
{{ help_label_tooltip.text|trans({}, translation_domain) }}
183+
{{ help_label_tooltip.text|trans(help_translation_parameters, translation_domain) }}
180184
{% endif %}
181185
</a>
182186
</span>
@@ -188,15 +192,15 @@ file that was distributed with this source code.
188192
{% endblock help_block_tooltip %}
189193

190194
{% block help_label_popover %}
191-
<span class="help-block">
195+
<span class="help-block text-muted">
192196
<a href="#" data-bs-toggle="popover" data-trigger="hover" data-placement="{{ help_label_popover.placement }}"
193-
title="{{ help_label_popover.title|trans({}, translation_domain) }}"
194-
data-content="{{ help_label_popover.content|trans({}, translation_domain) }}" data-html="true">
197+
title="{{ help_label_popover.title|trans(help_translation_parameters, translation_domain) }}"
198+
data-content="{{ help_label_popover.content|trans(help_translation_parameters, translation_domain) }}" data-html="true">
195199
{% if help_label_popover.icon is not same as(false) %}
196200
{{ networking_bootstrap_icon(help_label_popover.icon) }}
197201
{% endif %}
198202
{% if help_label_popover.text is not same as(null) %}
199-
{{ help_label_popover.text|raw }}
203+
{{ help_label_popover.text|trans(help_translation_parameters, translation_domain) }}
200204
{% endif %}
201205
</a>
202206
</span>
@@ -797,7 +801,7 @@ file that was distributed with this source code.
797801
{% endif %}
798802
{% apply spaceless %}
799803
{% for attrname,attrvalue in help_widget_popover %}
800-
data-bs-{{ attrname }}="{{ attrvalue|trans({}, domain|default('messages')) }}"
804+
data-bs-{{ attrname }}="{{ attrvalue|trans(help_translation_parameters, translation_domain|default('messages')) }}"
801805
{% endfor %}
802806
{% endapply %}
803807
{% endblock help_widget_popover %}

0 commit comments

Comments
 (0)