Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Dec 9, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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