10000 [Translation] Placeholder parameter is not replaced · Issue #49093 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[Translation] Placeholder parameter is not replaced #49093
Closed
@mhitza

Description

@mhitza

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0