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

Commit33c0ce3

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: Add documentation for pull #37371
2 parentsffd4b87 +064bb18 commit33c0ce3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎translation/message_format.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,22 @@ you to use literal text in the select statements:
173173
readable for translators and, as you can see in the ``other`` case, other
174174
parts of the sentence might be influenced by the variables.
175175

176+
..tip::
177+
178+
It's possible to translate ICU MessageFormat messages directly in code,
179+
without having to define them in any file::
180+
181+
$invitation = '{organizer_gender, select,
182+
female {{organizer_name} has invited you for her party!}
183+
male {{organizer_name} has invited you for his party!}
184+
other {{organizer_name} have invited you for their party!}
185+
}';
186+
187+
// prints "Ryan has invited you for his party!"
188+
echo $translator->trans($invitation, [
189+
'organizer_name' => 'Ryan',
190+
'organizer_gender' => 'male',
191+
]);
176192

177193
.. _component-translation-pluralization:
178194

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp