You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Given a translation defined in translations/messages.fr.yaml :
product:
add:
success: 'Le produit {id} a été ajouté!'
Translated using : $translator->trans('product.add.success', ['id' => 1234]);
I would except the message Le produit 1234 a été ajouté!', but the result was Le produit {1234} a été ajouté!`.
That's expected. The translator replaces placeholders as they are (i.e. in your case the call needs to be $translator->trans('product.add.success', ['{id}' => 1234]);). Note that there is not special meaning of the curly braces in regard to placeholders. You could also use the percent sign as often used too (i.e. having a message like 'Le produit %id% a été ajouté!' and then call the translator this way: $translator->trans('product.add.success', ['%id%' => 1234]);).
So I am going to close here as there is nothing to fix. Thank you for understanding.
Note that curly braces do have a special meaning when using the new ICU format. But for that, you would have to put your translation in messages+intl-icu.fr.yaml instead, to opt-in for the new format.
Symfony version(s) affected: 5.0.7
Description
Given a translation defined in
translations/messages.fr.yaml
:Translated using :
$translator->trans('product.add.success', ['id' => 1234]);
I would except the message
Le produit 1234 a été ajouté!', but the result was
Le produit {1234} a été ajouté!`.Apparently, I'm not the only one: https://stackoverflow.com/questions/59708205/symfony-translation-ignores-curly-braces-in-parameters
The text was updated successfully, but these errors were encountered: