@@ -103,19 +103,17 @@ are located:
103
103
;
104
104
};
105
105
106
- The locale used in translations is the one stored on the request. This is
107
- typically set via a ``_locale `` attribute on your routes (see :ref: `translation-locale-url `).
108
-
109
106
.. _translation-basic :
110
107
111
108
Basic Translation
112
109
-----------------
113
110
114
- Translation of text is done through the ``translator `` service
115
- (:class: `Symfony\\ Component\\ Translation\\ Translator `). To translate a block
116
- of text (called a *message *), use the
111
+ Translation of text is done through the ``translator `` service
112
+ (:class: `Symfony\\ Component\\ Translation\\ Translator `). To translate a block of
113
+ text (called a *message *), use the
117
114
:method: `Symfony\\ Component\\ Translation\\ Translator::trans ` method. Suppose,
118
- for example, that you're translating a static message from inside a controller::
115
+ for example, that you're translating a static message from inside a
116
+ controller::
119
117
120
118
// ...
121
119
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -251,25 +249,19 @@ The Translation Process
251
249
To actually translate the message, Symfony uses the following process when
252
250
using the ``trans() `` method:
253
251
254
- #. The ``locale `` of the current user, which is stored on the request is determined;
252
+ #. The ``locale `` of the current user, which is stored on the request is
253
+ determined; this is typically set via a ``_locale `` attribute on your routes
254
+ (see :ref: `translation-locale-url `);
255
255
256
- #. A catalog (e.g. big collection) of translated messages is loaded from translation
257
- resources defined for the ``locale `` (e.g. ``fr_FR ``). Messages from the
258
- :ref: `fallback locale <translation-fallback >` are also loaded and
259
- added to the catalog if they don't already exist. The end result is a large
260
- "dictionary" of translations. This catalog is cached in production to
261
- minimize performance impact.
256
+ #. A catalog of translated messages is loaded from translation resources
257
+ defined for the ``locale `` (e.g. ``fr_FR ``). Messages from the
258
+ :ref: `fallback locale <translation-fallback >` are also loaded and added to
259
+ the catalog if they don't already exist. The end result is a large
260
+ "dictionary" of translations.
262
261
263
262
#. If the message is located in the catalog, the translation is returned. If
264
263
not, the translator returns the original message.
265
264
266
- .. tip ::
267
-
268
- When translating strings that are not in the default domain (``messages ``),
269
- you must specify the domain as the third argument of ``trans() ``::
270
-
271
- $translator->trans('Symfony is great', [], 'admin');
272
-
273
265
.. _message-placeholders :
274
266
.. _pluralization :
275
267
@@ -297,22 +289,6 @@ To manage these situations, Symfony follows the `ICU MessageFormat`_ syntax by
297
289
using PHP's :phpclass: `MessageFormatter ` class. Read more about this in
298
290
:doc: `/translation/message_format `.
299
291
300
- .. tip ::
301
-
302
- If you don't use the ICU MessageFormat syntax in your translation files,
303
- pass a parameter named "%count%" to select the best plural form of the message:
304
-
305
- .. code-block :: twig
306
-
307
- {{ message|trans({'%name%': '...', '%count%': 1}, 'app') }}
308
-
309
- The ``message `` variable must include all the different versions of this
310
- message based on the value of the ``count `` parameter. For example:
311
-
312
- .. code-block :: text
313
-
314
- {0}%name% has no apples|{1}%name% has one apple|]1,Inf[ %name% has %count% apples
315
-
316
292
.. _translatable-objects :
317
293
318
294
Translatable Objects
0 commit comments