|
4 | 4 | Usage
|
5 | 5 | =====
|
6 | 6 |
|
7 |
| -Imagine you want to translate the string *"Symfony2 is great"* into french:: |
| 7 | +Imagine you want to translate the string *"Symfony2 is great"* into French:: |
8 | 8 |
|
9 | 9 | use Symfony\Component\Translation\Translator;
|
10 | 10 | use Symfony\Component\Translation\MessageSelector;
|
@@ -79,7 +79,8 @@ is done just as before:
|
79 | 79 | .. note::
|
80 | 80 |
|
81 | 81 | The placeholders can take on any form as the full message is reconstructed
|
82 |
| - using the PHP :phpfunction:`strtr function<strtr>`. |
| 82 | + using the PHP :phpfunction:`strtr function<strtr>`. But the ``%...%`` form |
| 83 | + is recommend, to avoid problems when using Twig. |
83 | 84 |
|
84 | 85 | As you've seen, creating a translation is a two-step process:
|
85 | 86 |
|
@@ -342,37 +343,8 @@ Or numbers between two other numbers:
|
342 | 343 | The left delimiter can be ``[`` (inclusive) or ``]`` (exclusive). The right
|
343 | 344 | delimiter can be ``[`` (exclusive) or ``]`` (inclusive). Beside numbers, you
|
344 | 345 |
|
345 |
| -.. _using-message-domains: |
346 |
| - |
347 |
| -Using Message Domains |
348 |
| -===================== |
349 |
| - |
350 |
| -As you've seen, message files are organized into the different locales that |
351 |
| -they translate. The message files can also be organized further into "domains". |
352 |
| - |
353 |
| -The domain is specific in the fourth argument of the ``addResource()`` method. |
354 |
| -The default domain is ``messages``. For example, suppose that, for organization, |
355 |
| -translations were split into three different domains: ``messages``, ``admin`` |
356 |
| -and ``navigation``. The French translation would be loaded like this:: |
357 |
| - |
358 |
| - // ... |
359 |
| - $translator->addLoader('xliff', new XliffLoader()); |
360 |
| - |
361 |
| - $translator->addResource('xliff', 'messages.fr.xliff', 'fr_FR'); |
362 |
| - $translator->addResource('xliff', 'admin.fr.xliff', 'fr_FR', 'admin'); |
363 |
| - $translator->addResource('xliff', 'navigation.fr.xliff', 'fr_FR', 'navigation'); |
364 |
| - |
365 |
| -When translating strings that are not in the default domain (``messages``), |
366 |
| -you must specify the domain as the third argument of ``trans()``:: |
367 |
| - |
368 |
| - $translator->trans('Symfony2 is great', array(), 'admin'); |
369 |
| - |
370 |
| -Symfony2 will now look for the message in the ``admin`` domain of the |
371 |
| -specified locale. |
372 |
| -can use ``-Inf`` and ``+Inf`` for the infinite. |
373 |
| - |
374 | 346 | Forcing the Translator Locale
|
375 |
| -============================= |
| 347 | +----------------------------- |
376 | 348 |
|
377 | 349 | When translating a message, the Translator uses the specified locale or the
|
378 | 350 | ``fallback`` locale if necessary. You can also manually specify the locale to
|
|
0 commit comments