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

Flash message : translation domain is not used in twig Alert component (since 4.20.4) #6743

Open
MrJuliuss opened this issue Jan 20, 2025 · 2 comments

Comments

@MrJuliuss
Copy link

MrJuliuss commented Jan 20, 2025

Describe the bug
Hi,
The translation domain is not used in new twig Alert component

To Reproduce

(>= 4.20.4)

In the new templates/flash_messages.html.twig, with a specific translation domain (which is not messages).

Works well with < 4.20.4 (without twig Alert component)

{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider #}
{% trans_default_domain ea.hasContext ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}

{# Just for check domain #}
{{ ea.hasContext ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') }}

{% set flash_messages = app.flashes %}

{% if flash_messages|length > 0 %}
    <div id="flash-messages">
        {% for label, messages in flash_messages %}
            {% for message in messages %}

                {# THIS LINE IS ADDED FOR TESTS #}
                {{ message|trans|raw }} {# correctly translated #}

                <twig:ea:Alert variant="{{ label }}" withDismissButton>
                    {{ message|trans|raw }} {# not translated, show only translation key #}
                </twig:ea:Alert>
            {% endfor %}
        {% endfor %}
    </div>
{% endif %}

@MrJuliuss
Copy link
Author

ping @javiereguiluz some regression on new alert component

@MrJuliuss
Copy link
Author

MrJuliuss commented Jan 20, 2025

It seems that the domain is lost in the twig component.

This test works :

 <twig:ea:Alert variant="{{ label }}" withDismissButton>
     {% trans_default_domain ea.hasContext ? ea.i18n.translationDomain : (translation_domain is defined ? translation_domain ?? 'messages') %}
     {{ message|trans|raw }}
  </twig:ea:Alert>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant