I'm trying to use message placeholders with Twig template engine. My navlist.it.yml
stores this message and its placeholder:
users:
label: Gestione utenti %app%
And in my Twig template i'd like to pass app name as a string. So what i'm doing is:
<ul class="nav nav-list">
<li class="nav-header">
{{ 'users.label'|trans({'app' : 'Fid'}, 'navlist')|raw }}
</li>
</ul>
Note i'm using raw
because users.label
may contain HTML. Output is exactly:
<li class="nav-header">Gestione utenti %Fid%</li>
So message is translated but extra %...%
are added. What i'm missing?
The percent signs are part of the pattern, so you should be adding them to the key of your translation values' array, like this:
{{ 'users.label'|trans({'%app%' : 'Fid'}, 'navlist')|raw }}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With