Skip to content

Commit 1d92b8e

Browse files
committed
[Translator] Fix example of using ICU message directly in code
1 parent a385ac1 commit 1d92b8e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

translation/message_format.rst

Lines changed: 11 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,15 @@ 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+
// Appends the required suffix "+intl-icu" to the domain
207+
'messages'.MessageCatalogueInterface::INTL_DOMAIN_SUFFIX
208+
);
202209

203210
.. _component-translation-pluralization:
204211

0 commit comments

Comments
 (0)