8000 Merge branch '4.4' into 5.0 · symfony/symfony-docs@38b8860 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 38b8860

Browse files 8000
committed
Merge branch '4.4' into 5.0
* 4.4: [#12400] Added tip about ranges in the new ICU message format Revert "[Transalation] Document range translation using the ICU MessageFormat" [Transalation] Document range translation using the ICU MessageFormat fix typo
2 parents c225f59 + 211503e commit 38b8860

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

setup/upgrade_major.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mentions of ``4.*`` to ``5.0.*``:
144144
}
145145
146146
At the bottom of your ``composer.json`` file, in the ``extra`` block you can
147-
find a data setting for the symfony version. Make sure to also upgrade
147+
find a data setting for the Symfony version. Make sure to also upgrade
148148
this one. For instance, update it to ``5.0.*`` to upgrade to Symfony 5.0:
149149

150150
.. code-block:: json

translation/message_format.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,27 @@ Usage of this string is the same as with variables and select::
263263
}
264264
}
265265
266+
.. sidebar:: Using Ranges in Messages
267+
268+
The pluralization in the legacy Symfony syntax could be used with custom
269+
ranges (e.g. have a different messages for 0-12, 12-40 and 40+). The ICU
270+
message format does not have this feature. Instead, this logic should be
271+
moved to PHP code::
272+
273+
// Instead of
274+
$message = $translator->trans('balance_message', $balance);
275+
// with a message like:
276+
// ]-Inf,0]Oops! I'm down|]0,1000]I still have money|]1000,Inf]I have lots of money
277+
278+
// use three different messages for each range:
279+
if ($balance < 0) {
280+
$message = $translator->trans('no_money_message');
281+
} elseif ($balance < 1000) {
282+
$message = $translator->trans('some_money_message');
283+
} else {
284+
$message = $translator->trans('lots_of_money_message');
285+
}
286+
266287
Additional Placeholder Functions
267288
--------------------------------
268289

0 commit comments

Comments
 (0)
0