Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Sep 25, 2023
1 parent dcb9f7e commit 6b2e218
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 3 additions & 4 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1233,9 +1233,10 @@ This is the name that's used to determine which dumper should be used.
translation.provider_factory
----------------------------

**Purpose**: To register a factory creating custom Translation Provider
**Purpose**: to register a factory related to custom translation providers

Register your factory as a service and tag it with ``translation.provider_factory``:
When creating custom :ref:`translation providers <translation-providers>`, you
must register your factory as a service and tag it with ``translation.provider_factory``:

.. configuration-block::

Expand Down Expand Up @@ -1270,8 +1271,6 @@ Register your factory as a service and tag it with ``translation.provider_factor
->addTag('translation.provider_factory')
;
For more details, see :ref:`translation providers <translation-providers>`.

.. _reference-dic-tags-twig-extension:

twig.extension
Expand Down
20 changes: 11 additions & 9 deletions translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -746,16 +746,18 @@ now use the following commands to push (upload) and pull (download) translations
# check out the command help to see its options (format, domains, locales, intl-icu, etc.)
$ php bin/console translation:pull --help
Creating custom Provider
~~~~~~~~~~~~~~~~~~~~~~~~
Creating Custom Providers
~~~~~~~~~~~~~~~~~~~~~~~~~

In addition to using Symfony's built-in translation providers, you can create
your own providers. To do so, you need to create two classes:

#. The first class must implement :class:`Symfony\\Component\\Translation\\Provider\\ProviderInterface`;
#. The second class needs to be a factory which will create instances of the first class. It must implement
:class:`Symfony\\Component\\Translation\\Provider\\ProviderFactoryInterface` (you can extend :class:`Symfony\\Component\\Translation\\Provider\\AbstractProviderFactory` to simplify its creation).

If you wish to create new Translation Provider, you need to create two classes.
First one must implement :class:`Symfony\\Component\\Translation\\Provider\\ProviderInterface`.
Second needs to be a factory, that will create instances of the first class. It must implement
:class:`Symfony\\Component\\Translation\\Provider\\ProviderFactoryInterface`.
You may extend :class:`Symfony\\Component\\Translation\\Provider\\AbstractProviderFactory`
to simplify its creation. Additionally you need to tag the factory service with
:ref:`translation.provider_factory <reference-dic-tags-translation-provider-factory>`.
After creating these two classes, you need to register your factory as a service
and tag it with :ref:`translation.provider_factory <reference-dic-tags-translation-provider-factory>`.

.. _translation-locale:

Expand Down

0 comments on commit 6b2e218

Please sign in to comment.