Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass menu label attributes to translation #6092

Closed
wants to merge 12 commits into from
Closed
6 changes: 3 additions & 3 deletions docs/reference/advanced_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ If you want to use the Tab Menu in a different way, you can replace the Menu Tem
Translations
^^^^^^^^^^^^

The translation parameters and domain can be customised by using the
``translation_domain`` and ``translation_parameters`` keys of the extra array
The label translation parameters and domain can be customised by using the
``label_translation_parameters`` and ``translation_domain`` keys of the extra array
of data associated with the item, respectively::

$menuItem->setExtras([
'translation_parameters' => ['myparam' => 'myvalue'],
'label_translation_parameters' => ['myparam' => 'myvalue'],
'translation_domain' => 'My domain',
pavol-tuka marked this conversation as resolved.
Show resolved Hide resolved
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/views/Menu/sonata_menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
{% endapply %}
{% endblock %}

{% block label %}{% if is_link is defined and is_link %}{{ icon|default|raw }}{% endif %}{% if options.allow_safe_labels and item.extra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label|trans({}, translation_domain|default('messages')) }}{% endif %}{% endblock %}
{% block label %}{% if is_link is defined and is_link %}{{ icon|default|raw }}{% endif %}{% if options.allow_safe_labels and item.extra('safe_label', false) %}{{ item.label|raw }}{% else %}{{ item.label|trans(item.extra('label_translation_parameters')|default({}), translation_domain|default('messages')) }}{% endif %}{% endblock %}
pavol-tuka marked this conversation as resolved.
Show resolved Hide resolved