symfony-docs icon indicating copy to clipboard operation
symfony-docs copied to clipboard

Update translation.rst

Open 94noni opened this issue 3 years ago • 2 comments

Based on https://github.com/symfony/demo/pull/1298#issuecomment-1000396048 and related PR

I did not touch the %count% as it seems specific I did not touch v4.4 also

94noni avatar Dec 23 '21 16:12 94noni

Are we 100% sure about this change?

In the TransNode class of Symfony Twig Bridge we can see that % are still used everywhere:

https://github.com/symfony/twig-bridge/blob/faed6ad85a2f8e675820422a74c4e0d5858a6821/Node/TransNode.php#L103-L128

javiereguiluz avatar Dec 27 '21 14:12 javiereguiluz

Are we 100% sure about this change?

well I've followed the related comment, maybe some ppl that knows translation better can review/help here

94noni avatar Dec 27 '21 15:12 94noni

The issue here is that implementations of the old format and the ICU message format treat the passed parameter names differently:

  • The old format replaces the parameter names as given (e.g. Hello %name% with 'name' => 'Fabien' becomes Hello %Fabien%)
  • The new format trims %{} from the parameter names, as ICU message knows what is a parameter and what is a plain string.

This means that, although unnecessary when using the ICU format, passing the parameter surrounded by percentage signs is compatible with both formats. As we currently document both formats, I would say it's better to keep using PHP examples that support both.

Btw, I think we should consider to stop documenting the old format some day (with maybe a note linking to an old version of the doc). At that moment, we can clean up all PHP examples.

wouterj avatar Oct 09 '22 20:10 wouterj