Closed
Description
Symfony version(s) affected
6.2.5
Description
Target translation message contains a placeholder %parameter% which is not replaced.
How to reproduce
I have a translation message in my messages.en.xlf
file:
<trans-unit id="gxuTKpj" resname="relative_date.last_week">
<source>relative_date.last_week</source>
<target>last week %day%</target>
</trans-unit>
And a twig extension which exposes a filter (relativeDate
) that returns a translatable message (simplified):
return new TranslatableMessage('relative_date.last_week', ['%day%' => match($dt->format('l')) {
'Monday' => new TranslatableMessage('relative_date.monday'),
'Tuesday' => new TranslatableMessage('relative_date.tuesday'),
'Wednesday' => new TranslatableMessage('relative_date.wednesday'),
'Thursday' => new TranslatableMessage('relative_date.thursday'),
'Friday' => new TranslatableMessage('relative_date.friday'),
'Saturday' => new TranslatableMessage('relative_date.saturday'),
default => new TranslatableMessage('relative_date.sunday')
}]);
Output which I use in my twig template:
<td class="p-2">{{ item.date|relativeDate|trans }}</td>
The end result is the message without replaced parameters:
<td class="p-2">last week %day%</td>
Possible Solution
No response
Additional Context
No response