Skip to content

Mentioned the extraction of translation contents from PHP files #11598

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions reference/configuration/twig.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or
disable these optimizations selectively, as explained in the Twig documentation
about `the optimizer extension`_.

.. _config-twig-default-path:

default_path
~~~~~~~~~~~~

Expand Down
23 changes: 13 additions & 10 deletions translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,23 +357,27 @@ with these tasks:

.. code-block:: terminal

# updates the French translation file with the missing strings found in templates/
# updates the French translation file with the missing strings for that locale
$ php bin/console translation:update --dump-messages --force fr

# updates the English translation file with the missing strings found in AppBundle
$ php bin/console translation:update --dump-messages --force en AppBundle
The ``translation:update`` command looks for missing translations in:

* Templates stored in the ``templates/`` directory (or any other directory
defined in the :ref:`twig.default_path <config-twig-default-path>` and
:ref:`twig.paths <config-twig-paths>` config options);
* Any PHP file/class that injects or :doc:`autowires </service_container/autowiring>`
the ``translator`` service and makes calls to the ``trans()`` function.

.. versionadded:: 4.3

The extraction of missing translation strings from PHP files was introduced
in Symfony 4.3.

.. note::

If you want to see the missing translation strings without actually updating
the translation files, remove the ``--force`` option from the command above.

.. tip::

If you need to extract translation strings from other sources, such as
controllers, forms and flash messages, consider using the more advanced
third-party `TranslationBundle`_.

.. _translation-resource-locations:

Translation Resource/File Names and Locations
Expand Down Expand Up @@ -564,4 +568,3 @@ Learn more
.. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
.. _`Translatable Extension`: http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html
.. _`Translatable Behavior`: https://github.com/KnpLabs/DoctrineBehaviors
.. _`TranslationBundle`: https://github.com/php-translation/symfony-bundle