@@ -159,75 +159,76 @@ the message inside your :ref:`templates <translation-tags>`.
159
159
160
160
.. _translation-real-vs-keyword-messages :
161
161
162
- .. sidebar :: Using Real or Keyword Messages
162
+ Using Real or Keyword Messages
163
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163
164
164
- This example illustrates the two different philosophies when creating
165
- messages to be translated::
165
+ This example illustrates the two different philosophies when creating
166
+ messages to be translated::
166
167
167
- $translator->trans('Symfony is great');
168
+ $translator->trans('Symfony is great');
168
169
169
- $translator->trans('symfony.great');
170
+ $translator->trans('symfony.great');
170
171
171
- In the first method, messages are written in the language of the default
172
- locale (English in this case). That message is then used as the "id"
173
- when creating translations.
172
+ In the first method, messages are written in the language of the default
173
+ locale (English in this case). That message is then used as the "id"
174
+ when creating translations.
174
175
175
- In the second method, messages are actually "keywords" that convey the
176
- idea of the message. The keyword message is then used as the "id" for
177
- any translations. In this case, translations must be made for the default
178
- locale (i.e. to translate ``symfony.great `` to ``Symfony is great ``).
176
+ In the second method, messages are actually "keywords" that convey the
177
+ idea of the message. The keyword message is then used as the "id" for
178
+ any translations. In this case, translations must be made for the default
179
+ locale (i.e. to translate ``symfony.great `` to ``Symfony is great ``).
179
180
180
- The second method is handy because the message key won't need to be changed
181
- in every translation file if you decide that the message should actually
182
- read "Symfony is really great" in the default locale.
181
+ The second method is handy because the message key won't need to be changed
182
+ in every translation file if you decide that the message should actually
183
+ read "Symfony is really great" in the default locale.
183
184
184
- The choice of which method to use is entirely up to you, but the "keyword"
185
- format is often recommended for multi-language applications, whereas for
186
- shared bundles that contain translation resources we recommend the real
187
- message, so your application can choose to disable the translator layer
188
- and you will see a readable message.
185
+ The choice of which method to use is entirely up to you, but the "keyword"
186
+ format is often recommended for multi-language applications, whereas for
187
+ shared bundles that contain translation resources we recommend the real
188
+ message, so your application can choose to disable the translator layer
189
+ and you will see a readable message.
189
190
190
- Additionally, the ``php `` and ``yaml `` file formats support nested ids to
191
- avoid repeating yourself if you use keywords instead of real text for your
192
- ids:
191
+ Additionally, the ``php `` and ``yaml `` file formats support nested ids to
192
+ avoid repeating yourself if you use keywords instead of real text for your
193
+ ids:
193
194
194
- .. configuration-block ::
195
+ .. configuration-block ::
195
196
196
- .. code-block :: yaml
197
+ .. code-block :: yaml
197
198
198
- symfony :
199
- is :
200
- # id is symfony.is.great
201
- great : Symfony is great
202
- # id is symfony.is.amazing
203
- amazing : Symfony is amazing
204
- has :
205
- # id is symfony.has.bundles
206
- bundles : Symfony has bundles
207
- user :
208
- # id is user.login
209
- login : Login
199
+ symfony :
200
+ is :
201
+ # id is symfony.is.great
202
+ great : Symfony is great
203
+ # id is symfony.is.amazing
204
+ amazing : Symfony is amazing
205
+ has :
206
+ # id is symfony.has.bundles
207
+ bundles : Symfony has bundles
208
+ user :
209
+ # id is user.login
210
+ login : Login
210
211
211
- .. code-block :: php
212
+ .. code-block :: php
212
213
213
- [
214
- 'symfony' => [
215
- 'is' => [
216
- // id is symfony.is.great
217
- 'great' => 'Symfony is great',
218
- // id is symfony.is.amazing
219
- 'amazing' => 'Symfony is amazing',
220
- ],
221
- 'has' => [
222
- // id is symfony.has.bundles
223
- 'bundles' => 'Symfony has bundles',
224
- ],
214
+ [
215
+ 'symfony' => [
216
+ 'is' => [
217
+ // id is symfony.is.great
218
+ 'great' => 'Symfony is great',
219
+ // id is symfony.is.amazing
220
+ 'amazing' => 'Symfony is amazing',
225
221
],
226
- 'user ' => [
227
- // id is user.login
228
- 'login ' => 'Login ',
222
+ 'has ' => [
223
+ // id is symfony.has.bundles
224
+ 'bundles ' => 'Symfony has bundles ',
229
225
],
230
- ];
226
+ ],
227
+ 'user' => [
228
+ // id is user.login
229
+ 'login' => 'Login',
230
+ ],
231
+ ];
231
232
232
233
The Translation Process
233
234
~~~~~~~~~~~~~~~~~~~~~~~
0 commit comments