Commit 06898fb1 authored by Benoit Pointet's avatar Benoit Pointet

corrected translation doc

parent 49f00191
...@@ -128,7 +128,9 @@ And that's all you need to load translations from YAML files. ...@@ -128,7 +128,9 @@ And that's all you need to load translations from YAML files.
XLIFF-based language files XLIFF-based language files
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
Just as you would do with YAML translation files, you first need to make sure you have the ``Config`` component from Symfony2, and that they are registered with the autoloader. See above for details. Just as you would do with YAML translation files, you first need to make
sure you have the ``Config`` component from Symfony2, and that they are
registered with the autoloader. See above for details.
Then, similarly, create XLIFF files in your locales directory and setup the ``translator.messages`` to map to them. Then, similarly, create XLIFF files in your locales directory and setup the ``translator.messages`` to map to them.
...@@ -142,7 +144,16 @@ That's it. ...@@ -142,7 +144,16 @@ That's it.
Adding translations in Twig templates Adding translations in Twig templates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The translation service provider is available from within Twig templates: Once loaded, the translation service provider is available from within Twig templates:
.. code-block:: twig .. code-block:: jinja
{{ app.translator.trans('translation_key') }} {{ app.translator.trans('translation_key') }}
Even better: register the SymfonyBridgesServiceProvider and you will get
the TranslationExtension of the bridge allowing you to translate things in
the Twig way:
.. code-block:: jinja
{{ 'translation_key'|trans }}
{{ 'translation_key'|transchoice }}
{% trans %}translation_key{% endtrans %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment