Skip to content

Commit 8829154

Browse files
committed
Reword
1 parent e349a74 commit 8829154

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

translation.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,22 @@ To manage these situations, Symfony follows the `ICU MessageFormat`_ syntax by
297297
using PHP's :phpclass:`MessageFormatter` class. Read more about this in
298298
:doc:`/translation/message_format`.
299299

300+
.. tip::
301+
302+
If you don't use the ICU MessageFormat syntax in your translation files,
303+
pass a parameter named "%count%" to select the best plural form of the message:
304+
305+
.. code-block:: twig
306+
307+
{{ message|trans({'%name%': '...', '%count%' => 1}, 'app') }}
308+
309+
The ``message`` variable must include all the different versions of this
310+
message based on the value of the ``count`` parameter. For example:
311+
312+
.. code-block:: text
313+
314+
{0}%name% has no apples|{1}%name% has one apple|]1,Inf[ %name% has %count% apples
315+
300316
.. _translatable-objects:
301317

302318
Translatable Objects
@@ -410,15 +426,6 @@ The ``trans`` filter can be used to translate *variable texts* and complex expre
410426
{{ message|trans|raw }}
411427
{{ '<h3>bar</h3>'|trans|raw }}
412428
413-
.. tip::
414-
415-
When a number is provided as a parameter named "%count%", the message is parsed for plural
416-
forms and a translation is chosen according to this number using the following rules:
417-
418-
.. code-block:: twig
419-
420-
{{ message|trans({'%name%': 'Fabien', '%count%' => 1}, 'app') }}
421-
422429
.. tip::
423430

424431
You can set the translation domain for an entire Twig template with a single tag:

0 commit comments

Comments
 (0)