Skip to content

Commit 045a168

Browse files
authored
Merge pull request #5384 from kenjis/fix-docs-localization.rst
docs: fix localization.rst
2 parents a1ab2aa + 96381ea commit 045a168

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

user_guide_src/source/outgoing/localization.rst

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ supported language::
2020
/app
2121
/Language
2222
/en
23-
app.php
23+
App.php
2424
/fr
25-
app.php
25+
App.php
2626

2727
.. important:: Locale detection only works for web-based requests that use the IncomingRequest class.
2828
Command-line requests will not have these features.
@@ -119,20 +119,16 @@ You might name it simply: **Errors.php**.
119119

120120
Within the file, you would return an array, where each element in the array has a language key and can have string to return::
121121

122-
'language_key' => 'The actual message to be shown.'
122+
'languageKey' => 'The actual message to be shown.'
123123

124124
It also support nested definition::
125125

126-
'language_key' => [
126+
'languageKey' => [
127127
'nested' => [
128128
'key' => 'The actual message to be shown.',
129129
],
130130
],
131131

132-
.. note:: It's good practice to use a common prefix for all messages in a given file to avoid collisions with
133-
similarly named items in other files. For example, if you are creating error messages you might prefix them
134-
with error\_
135-
136132
::
137133

138134
return [
@@ -174,9 +170,9 @@ You can pass an array of values to replace placeholders in the language string a
174170

175171
// The language file, Tests.php:
176172
return [
177-
"apples" => "I have {0, number} apples.",
178-
"men" => "The top {1, number} men out-performed the remaining {0, number}",
179-
"namedApples" => "I have {number_apples, number, integer} apples.",
173+
'apples' => 'I have {0, number} apples.',
174+
'men' => 'The top {1, number} men out-performed the remaining {0, number}',
175+
'namedApples' => 'I have {number_apples, number, integer} apples.',
180176
];
181177

182178
// Displays "I have 3 apples."
@@ -190,7 +186,7 @@ The first item in the placeholder corresponds to the index of the item in the ar
190186
You can also use named keys to make it easier to keep things straight, if you'd like::
191187

192188
// Displays "I have 3 apples."
193-
echo lang("Tests.namedApples", ['number_apples' => 3]);
189+
echo lang('Tests.namedApples', ['number_apples' => 3]);
194190

195191
Obviously, you can do more than just number replacement. According to the
196192
`official ICU docs <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classMessageFormat.html#details>`_ for the underlying

0 commit comments

Comments
 (0)