Skip to content

[Translation] Update the PHP extraction information for Symfony 7.0 #18516

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 1 commit into from
Jul 7, 2023
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
15 changes: 4 additions & 11 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1071,23 +1071,16 @@ file

When executing the ``translation:extract`` command, it uses extractors to
extract translation messages from a file. By default, the Symfony Framework
has a :class:`Symfony\\Bridge\\Twig\\Translation\\TwigExtractor` and a PHP
extractor to find and extract translation keys from Twig templates and PHP files.
has a :class:`Symfony\\Bridge\\Twig\\Translation\\TwigExtractor` to find and
extract translation keys from Twig templates.

Symfony includes two PHP extractors: :class:`Symfony\\Component\\Translation\\Extractor\\PhpExtractor`
and :class:`Symfony\\Component\\Translation\\Extractor\\PhpAstExtractor`. The
first one is simple but doesn't require to install any packages; the second one
is much more advanced, but requires to install this dependency in your project:
If you also want to find and extract translation keys from PHP files, install
the following dependency to activate the :class:`Symfony\\Component\\Translation\\Extractor\\PhpAstExtractor`:

.. code-block:: terminal

$ composer require nikic/php-parser

.. deprecated:: 6.2

The ``PhpExtractor`` class is deprecated since Symfony 6.2. The ``PhpAstExtractor``
class will be the only PHP extractor available starting from Symfony 7.0.

You can create your own extractor by creating a class that implements
:class:`Symfony\\Component\\Translation\\Extractor\\ExtractorInterface`
and tagging the service with ``translation.extractor``. The tag has one
Expand Down