@@ -20,9 +20,9 @@ supported language::
20
20
/app
21
21
/Language
22
22
/en
23
- app .php
23
+ App .php
24
24
/fr
25
- app .php
25
+ App .php
26
26
27
27
.. important :: Locale detection only works for web-based requests that use the IncomingRequest class.
28
28
Command-line requests will not have these features.
@@ -119,20 +119,16 @@ You might name it simply: **Errors.php**.
119
119
120
120
Within the file, you would return an array, where each element in the array has a language key and can have string to return::
121
121
122
- 'language_key ' => 'The actual message to be shown.'
122
+ 'languageKey ' => 'The actual message to be shown.'
123
123
124
124
It also support nested definition::
125
125
126
- 'language_key ' => [
126
+ 'languageKey ' => [
127
127
'nested' => [
128
128
'key' => 'The actual message to be shown.',
129
129
],
130
130
],
131
131
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
-
136
132
::
137
133
138
134
return [
@@ -174,9 +170,9 @@ You can pass an array of values to replace placeholders in the language string a
174
170
175
171
// The language file, Tests.php:
176
172
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.' ,
180
176
];
181
177
182
178
// 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
190
186
You can also use named keys to make it easier to keep things straight, if you'd like::
191
187
192
188
// Displays "I have 3 apples."
193
- echo lang(" Tests.namedApples" , ['number_apples' => 3]);
189
+ echo lang(' Tests.namedApples' , ['number_apples' => 3]);
194
190
195
191
Obviously, you can do more than just number replacement. According to the
196
192
`official ICU docs <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classMessageFormat.html#details >`_ for the underlying
0 commit comments