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

Appearance settings

Commit 064bb18

Browse filesBrowse files
committed
Tweaks
1 parent 4a6be29 commit 064bb18
Copy full SHA for 064bb18

File tree

1 file changed

+16
-15
lines changed
Filter options

1 file changed

+16
-15
lines changed

‎translation/message_format.rst

Copy file name to clipboardExpand all lines: translation/message_format.rst
+16-15Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,6 @@ you to use literal text in the select statements:
165165
#. Inside this block, ``{organizer_name}`` starts "code" mode again, allowing
166166
``organizer_name`` to be processed as variable.
167167

168-
Additionally, it's possible to write the message directly in code::
169-
170-
$invitation = '{organizer_gender, select,
171-
female {{organizer_name} has invited you for her party!}
172-
male {{organizer_name} has invited you for his party!}
173-
other {{organizer_name} have invited you for their party!}
174-
}';
175-
// prints "Ryan has invited you for his party!"
176-
echo $translator->trans($invitation, [
177-
'organizer_name' => 'Ryan',
178-
'organizer_gender' => 'male',
179-
]);
180-
181-
This can be used to create a wrapper.
182-
183168
.. tip::
184169

185170
While it might seem more logical to only put ``her``, ``his`` or ``their``
@@ -188,6 +173,22 @@ This can be used to create a wrapper.
188173
readable for translators and, as you can see in the ``other`` case, other
189174
parts of the sentence might be influenced by the variables.
190175

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+
]);
191192

192193
.. _component-translation-pluralization:
193194

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.