Skip to content

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

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

Merged
merged 7 commits into from
Dec 9, 2015
Merged
Changes from 4 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
14 changes: 13 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,18 @@ 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::

The paths at which Symfony will look for message files can be modified by adding
your custom resources path in your config.yml file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this more direct and shorter (shorter = better is quite an important rule in documentations): You can add other directories with the ``paths`` option in the configuration:


.. code-block:: yaml

framework:
translator:
paths:
- %kernel.root_dir%/../vendor/Symfony/Component/Form/Resources/translations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should document the other formats as well:

.. 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