-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
translations/messages.en.yaml ``` item_label_translation: Translatable label with %placeholder%. ``` Menu builder ``` $group->addChild('item', [ 'label' => 'item_label_translation', 'labelAttributes' => ['%placeholder%' => 'dynamic_value'] ]); ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should target 3.x
, since there is no BC break in this addition.
IMHO If I understand correctly the option, the best name is This would fit with symfony option: https://symfony.com/doc/current/reference/forms/types/choice.html#label-translation-parameters Edit: Seems like this was an already documented option, https://symfony.com/doc/master/bundles/SonataAdminBundle/reference/advanced_configuration.html#translations But when I looked in the code, there is no use of |
I agree. We should deprecate the existing option in order to be consistent with "label_translation_parameters". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not fully related, but, seems like the translation_domain
is defined this way in the block linkElement and the block spanElement:
{% set translation_domain = item.extra('label_catalogue', 'messages') %}
First of all, the option used should be translation_domain
and not label_catalogue
.
Secondly, seems like the variable translation_domain
is not defined in the block label, so it always default to messages
.
I would recommend to use:
{# NEXT_MAJOR: Remove the deprecated option 'label_catalogue' #}
{% set translation_domain = item.extra('label_catalogue', item.extra('translation_domain', 'messages')) %}
line 25, 39, and adding this variable inside the block label
.
Co-authored-by: Vincent Langlet <[email protected]>
Does someone use the When I look at the doc, it say:
But when I look at the code, all I see is If the actual working options are
This will avoid to start changing 19 occurences, adding a deprecation note, etc, in a non-related small PR which was created to add a missing option. |
I have installed
and I see (in translation panel of profiler) that its completly ignored. It uses domain
If you agree, I can do it :) |
I think the
I agree,
You mean
Yes
Yes
Great :) |
Co-authored-by: Vincent Langlet <[email protected]>
@@ -1,43 +1,43 @@ | |||
{% extends 'knp_menu.html.twig' %} | |||
|
|||
{% block root %} | |||
{%- set listAttributes = item.childrenAttributes|merge({'class': 'sidebar-menu', 'data-widget': 'tree'}) %} | |||
{%- set request = item.extra('request') ?: app.request %} | |||
{%- set listAttributes = item.childrenAttributes|merge({'class': 'sidebar-menu', 'data-widget': 'tree'}) -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure of the impact of adding -
in all the tag of block root
, block item
, etc.
Maybe it's better to limit the change to block label
in order to avoid regression.
But I let the choice to other reviewers.
@pavol-tk Can you make this PR on 3.x instead of master ? A way to do this is
With every commit hash of your PR. |
@VincentLanglet thank you for your steps to do it. #6112 |
Subject
Allow to use parameters/placeholders in (sidebar) menu label.
translations/messages.en.yaml
Menu builder: