Skip to content

Commit

Permalink
feature symfony#5954 Fix symfony#5236 [2.8][Translation] specify addi…
Browse files Browse the repository at this point in the history
…tional translation loading paths (Pierre Maraitre, Balamung)

This PR was merged into the 2.8 branch.

Discussion
----------

Fix symfony#5236 [2.8][Translation] specify additional translation loading paths

My humble try of contributing from the SymfonyCon Hackday ! :)

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes
| Applies to    | 2.8
| Fixed tickets | symfony#5236

Commits
-------

46de0d6 Delete pmaraitre.xml
b3fa941 Adding configuration examples for other formats
2cabebe Replace with a shorter phrase
0d8eadc Wrong code-block tag
c220cd0 Clearer formulation
40b7b78 Double "the"
f87f5f4 Fix symfony#5236 [Translation] specify additional translation loading paths
  • Loading branch information
xabbuh committed Dec 9, 2015
2 parents 63dd246 + 46de0d6 commit d58cb56
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ The translator service is accessible in PHP templates through the
Translation Resource/File Names and Locations
---------------------------------------------

Symfony looks for message files (i.e. translations) in the following locations:
Symfony looks for message files (i.e. translations) in the following default locations:

* the ``app/Resources/translations`` directory;

Expand Down Expand Up @@ -372,6 +372,49 @@ The choice of which loader to use is entirely up to you and is a matter of
taste. The recommended option is to use ``xlf`` for translations.
For more options, see :ref:`component-translator-message-catalogs`.

.. note::

You can add other directories with the ``paths`` option in the configuration:

.. configuration-block::

.. code-block:: yaml
# app/config/config.yml
framework:
translator:
paths:
- "%kernel.root_dir%/../translations"
.. code-block:: xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
>
<framework:config>
<framework:translator>
<framework:path>%kernel.root_dir%/../translations</framework:path>
</framework:translator>
</framework:config>
</container>
.. code-block:: php
$container->loadFromExtension('framework', array(
'translator' => array(
'paths' => array(
'%kernel.root_dir%/../translations'
)
),
));
.. note::

You can also store translations in a database, or any other storage by
Expand Down

0 comments on commit d58cb56

Please sign in to comment.