@@ -9,7 +9,7 @@ How to Translate Messages using the ICU MessageFormat
99 Support for ICU MessageFormat was introduced in Symfony 4.2.
1010
1111Messages (i.e. strings) in applications are almost never completely static.
12- They contain variables or other complex logic like pluralization. In order to
12+ They contain variables or other complex logic like pluralization. To
1313handle this, the Translator component supports the `ICU MessageFormat `_ syntax.
1414
1515.. tip ::
@@ -92,7 +92,7 @@ Selecting Different Messages Based on a Condition
9292
9393The curly brace syntax allows to "modify" the output of the variable. One of
9494these functions is the ``select `` function. It acts like PHP's `switch statement `_
95- and allows to use different strings based on the value of the variable. A
95+ and allows you to use different strings based on the value of the variable. A
9696typical usage of this is gender:
9797
9898.. configuration-block ::
@@ -104,9 +104,9 @@ typical usage of this is gender:
104104 # the 'other' key is required, and is selected if no other case matches
105105 invitation_title : >-
106106 {organizer_gender, select,
107- female {{organizer_name} has invited you for her party!}
108- male {{organizer_name} has invited you for his party!}
109- other {{organizer_name} have invited you for their party!}
107+ female {{organizer_name} has invited you to her party!}
108+ male {{organizer_name} has invited you to his party!}
109+ other {{organizer_name} have invited you to their party!}
110110 }
111111
112112 .. code-block :: xml
@@ -120,9 +120,9 @@ typical usage of this is gender:
120120 <source >invitation_title</source >
121121 <!-- the 'other' key is required, and is selected if no other case matches -->
122122 <target >{organizer_gender, select,
123- female {{organizer_name} has invited you for her party!}
124- male {{organizer_name} has invited you for his party!}
125- other {{organizer_name} have invited you for their party!}
123+ female {{organizer_name} has invited you to her party!}
124+ male {{organizer_name} has invited you to his party!}
125+ other {{organizer_name} have invited you to their party!}
126126 }</target >
127127 </trans-unit >
128128 </body >
@@ -135,9 +135,9 @@ typical usage of this is gender:
135135 return [
136136 // the 'other' key is required, and is selected if no other case matches
137137 'invitation_title' => '{organizer_gender, select,
138- female {{organizer_name} has invited you for her party!}
139- male {{organizer_name} has invited you for his party!}
140- other {{organizer_name} have invited you for their party!}
138+ female {{organizer_name} has invited you to her party!}
139+ male {{organizer_name} has invited you to his party!}
140+ other {{organizer_name} have invited you to their party!}
141141 }',
142142 ];
143143
@@ -147,13 +147,13 @@ later, ``function_statement`` is optional for some functions). In this case,
147147the function name is ``select `` and its statement contains the "cases" of this
148148select. This function is applied over the ``organizer_gender `` variable::
149149
150- // prints "Ryan has invited you for his party!"
150+ // prints "Ryan has invited you to his party!"
151151 echo $translator->trans('invitation_title', [
152152 'organizer_name' => 'Ryan',
153153 'organizer_gender' => 'male',
154154 ]);
155155
156- // prints "John & Jane have invited you for their party!"
156+ // prints "John & Jane have invited you to their party!"
157157 echo $translator->trans('invitation_title', [
158158 'organizer_name' => 'John & Jane',
159159 'organizer_gender' => 'not_applicable',
@@ -164,10 +164,10 @@ you to use literal text in the select statements:
164164
165165#. The first ``{organizer_gender, select, ...} `` block starts the "code" mode,
166166 which means ``organizer_gender `` is processed as a variable.
167- #. The inner ``{... has invited you for her party!} `` block brings you back in
167+ #. The inner ``{... has invited you to her party!} `` block brings you back in
168168 "literal" mode, meaning the text is not processed.
169169#. Inside this block, ``{organizer_name} `` starts "code" mode again, allowing
170- ``organizer_name `` to be processed as variable.
170+ ``organizer_name `` to be processed as a variable.
171171
172172.. tip ::
173173
@@ -225,7 +225,7 @@ handle pluralization in your messages (e.g. ``There are 3 apples`` vs
225225 Pluralization rules are actually quite complex and differ for each language.
226226For instance, Russian uses different plural forms for numbers ending with 1;
227227numbers ending with 2, 3 or 4; numbers ending with 5, 6, 7, 8 or 9; and even
228- some exceptions of this!
228+ some exceptions to this!
229229
230230In order to properly translate this, the possible cases in the ``plural ``
231231function are also different for each language. For instance, Russian has
@@ -279,7 +279,7 @@ Usage of this string is the same as with variables and select::
279279 .. sidebar :: Using Ranges in Messages
280280
281281 The pluralization in the legacy Symfony syntax could be used with custom
282- ranges (e.g. have a different messages for 0-12, 12-40 and 40+). The ICU
282+ ranges (e.g. have different messages for 0-12, 12-40 and 40+). The ICU
283283 message format does not have this feature. Instead, this logic should be
284284 moved to PHP code::
285285
0 commit comments