Symfony / Twig does not translate correctly when using message placeholders

I am trying to use message composers with the Twig template engine. Mine navlist.it.ymlstores this message and its placeholder:

users:
  label: Gestione utenti %app%

And in my Twig template, I would like to pass the application name as a string. So what I am doing:

<ul class="nav nav-list">
    <li class="nav-header">
        {{ 'users.label'|trans({'app' : 'Fid'}, 'navlist')|raw }}
    </li>
</ul>

Note. I use rawbecause it users.labelmay contain HTML. Conclusion for sure:

<li class="nav-header">Gestione utenti %Fid%</li>

So, the message is translated, but additional ones are added %...%. What am I missing?

+5
source share
1 answer

Percent signs are part of the template, so you must add them to the key of the array of translation values, for example:

{{ 'users.label'|trans({'%app%' : 'Fid'}, 'navlist')|raw }}
+8
source

All Articles