Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5832ae

Browse files
committed
minor#16905 [Translation] Fix example of using ICU message directly in code (HypeMC)
This PR was merged into the 5.4 branch.Discussion----------[Translation] Fix example of using ICU message directly in codeFixes#15402 &symfony/symfony#46723Commits-------1d92b8e [Translator] Fix example of using ICU message directly in code
2 parents7aac8ea +1d92b8e commitc5832ae

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)

[8]ページ先頭

©2009-2025 Movatter.jp