Skip to content

Commit a608dce

Browse files
committed
Merge branch '6.1' into 6.2
* 6.1: [Translator] Fix example of using ICU message directly in code
2 parents d544e68 + c14eda0 commit a608dce

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

translation/message_format.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ you to use literal text in the select statements:
187187
It's possible to translate ICU MessageFormat messages directly in code,
188188
without having to define them in any file::
189189

190+
use Symfony\Component\Translation\MessageCatalogueInterface;
191+
190192
$invitation = '{organizer_gender, select,
191193
female {{organizer_name} has invited you to her party!}
192194
male {{organizer_name} has invited you to his party!}
@@ -195,10 +197,16 @@ you to use literal text in the select statements:
195197
}';
196198

197199
// prints "Ryan has invited you to his party!"
198-
echo $translator->trans($invitation, [
199-
'organizer_name' => 'Ryan',
200-
'organizer_gender' => 'male',
201-
]);
200+
echo $translator->trans(
201+
$invitation,
202+
[
203+
'organizer_name' => 'Ryan',
204+
'organizer_gender' => 'male',
205+
],
206+
// if you prefer, the required "+intl-icu" suffix is also defined as a constant:
207+
// Symfony\Component\Translation\MessageCatalogueInterface::INTL_DOMAIN_SUFFIX
208+
'messages+intl-icu'
209+
);
202210

203211
.. _component-translation-pluralization:
204212

0 commit comments

Comments
 (0)