Skip to content

Commit d58cb56

Browse files
committed
feature #5954 Fix #5236 [2.8][Translation] specify additional translation loading paths (Pierre Maraitre, Balamung)
This PR was merged into the 2.8 branch. Discussion ---------- Fix #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 | #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 #5236 [Translation] specify additional translation loading paths
2 parents 63dd246 + 46de0d6 commit d58cb56

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

book/translation.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ The translator service is accessible in PHP templates through the
334334
Translation Resource/File Names and Locations
335335
---------------------------------------------
336336

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

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

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

375+
.. note::
376+
377+
You can add other directories with the ``paths`` option in the configuration:
378+
379+
.. configuration-block::
380+
381+
.. code-block:: yaml
382+
383+
# app/config/config.yml
384+
framework:
385+
translator:
386+
paths:
387+
- "%kernel.root_dir%/../translations"
388+
389+
.. code-block:: xml
390+
391+
<?xml version="1.0" encoding="UTF-8" ?>
392+
<container xmlns="http://symfony.com/schema/dic/services"
393+
xmlns:framework="http://symfony.com/schema/dic/symfony"
394+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
395+
xsi:schemaLocation="http://symfony.com/schema/dic/services
396+
http://symfony.com/schema/dic/services/services-1.0.xsd
397+
http://symfony.com/schema/dic/symfony
398+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"
399+
>
400+
401+
<framework:config>
402+
<framework:translator>
403+
<framework:path>%kernel.root_dir%/../translations</framework:path>
404+
</framework:translator>
405+
</framework:config>
406+
</container>
407+
408+
.. code-block:: php
409+
410+
$container->loadFromExtension('framework', array(
411+
'translator' => array(
412+
'paths' => array(
413+
'%kernel.root_dir%/../translations'
414+
)
415+
),
416+
));
417+
375418
.. note::
376419

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

0 commit comments

Comments
 (0)