Skip to content

Commit 47bc349

Browse files
javiereguiluzweaverryan
authored andcommitted
Better docs about overriding third-party translations
1 parent 3a09ccc commit 47bc349

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

bundles/override.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,12 @@ instead of the original ones.
149149
Translations
150150
------------
151151

152-
Translations are not related to bundles, but to domains. That means that you
153-
can override the translations from any translation file, as long as it is in
154-
:ref:`the correct domain <using-message-domains>`.
152+
Translations are not related to bundles, but to :ref:`translation domains <using-message-domains>`.
153+
For this reason, you can override any bundle translation file from the main
154+
``translations/`` directory, as long as the new file uses the same domain.
155+
156+
For example, to override the translations defined in the
157+
``Resources/translations/FOSUserBundle.es.yml`` file of the FOSUserBundle,
158+
create a``<your-project>/translations/FOSUserBundle.es.yml`` file.
155159

156160
.. _`the Doctrine documentation`: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/inheritance-mapping.html#overrides

configuration/override_dir_structure.rst

+48
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,54 @@ own templates directory (or directories):
129129
),
130130
));
131131
132+
Override the Translations Directory
133+
-----------------------------------
134+
135+
If your translation files are not stored in the default ``translations/``
136+
directory, use the :ref:`framework.translator.paths <reference-translator-paths>`
137+
configuration option to define your own translations directory (or directories):
138+
139+
.. configuration-block::
140+
141+
.. code-block:: yaml
142+
143+
# config/packages/translation.yaml
144+
framework:
145+
translator:
146+
# ...
147+
paths: ["%kernel.project_dir%/i18n"]
148+
149+
.. code-block:: xml
150+
151+
<!-- config/packages/translation.xml -->
152+
<?xml version="1.0" ?>
153+
<container xmlns="http://symfony.com/schema/dic/services"
154+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
155+
xmlns:twig="http://symfony.com/schema/dic/twig"
156+
xsi:schemaLocation="http://symfony.com/schema/dic/services
157+
http://symfony.com/schema/dic/services/services-1.0.xsd
158+
http://symfony.com/schema/dic/twig
159+
http://symfony.com/schema/dic/twig/twig-1.0.xsd">
160+
161+
<framework:config>
162+
<framework:translator>
163+
<framework:path>%kernel.project_dir%/i18n</framework:path>
164+
</framework:translator>
165+
</framework:config>
166+
167+
</container>
168+
169+
.. code-block:: php
170+
171+
// config/packages/translation.php
172+
$container->loadFromExtension('framework', array(
173+
'translator' => array(
174+
'paths' => array(
175+
'%kernel.project_dir%/i18n',
176+
),
177+
),
178+
));
179+
132180
.. _override-web-dir:
133181
.. _override-the-web-directory:
134182

0 commit comments

Comments
 (0)