Skip to content

Commit

Permalink
minor #4247 [Reference] link translation DIC tags to components secti…
Browse files Browse the repository at this point in the history
…on (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Reference] link translation DIC tags to components section

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets |

The `translation.loader` and `translation.dumper` DIC tags link to the respective sections in the Translation component documentation (in addition to the changes done in #4166).

Commits
-------

9790975 link translation DIC tags to components section
  • Loading branch information
weaverryan committed Sep 22, 2014
2 parents 082755d + 9790975 commit efc1436
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
4 changes: 4 additions & 0 deletions components/translation/custom_formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ message. A translation file would look like this:
(goodbye)(au revoir)
(hello)(bonjour)
.. _components-translation-custom-loader:

Creating a Custom Loader
------------------------

Expand Down Expand Up @@ -65,6 +67,8 @@ Once created, it can be used as any other loader::

It will print *"accueil"*.

.. _components-translation-custom-dumper:

Creating a Custom Dumper
------------------------

Expand Down
33 changes: 9 additions & 24 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1029,32 +1029,12 @@ translation.loader
**Purpose**: To register a custom service that loads translations
By default, translations are loaded from the filesystem in a variety of different
formats (YAML, XLIFF, PHP, etc). If you need to load translations from some
other source, first create a class that implements the
:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface::
formats (YAML, XLIFF, PHP, etc).
// src/Acme/MainBundle/Translation/MyCustomLoader.php
namespace Acme\MainBundle\Translation;
use Symfony\Component\Translation\Loader\LoaderInterface;
use Symfony\Component\Translation\MessageCatalogue;
class MyCustomLoader implements LoaderInterface
{
public function load($resource, $locale, $domain = 'messages')
{
$catalogue = new MessageCatalogue($locale);
// some how load up some translations from the "resource"
// then set them into the catalogue
$catalogue->set('hello.world', 'Hello World!', $domain);
return $catalogue;
}
}
.. seealso::
Your custom loader's ``load`` method is responsible for returning a
:Class:`Symfony\\Component\\Translation\\MessageCatalogue`.
Learn how to :ref:`load custom formats <components-translation-custom-loader>`
in the components section.
Now, register your loader as a service and tag it with ``translation.loader``:
Expand Down Expand Up @@ -1252,6 +1232,11 @@ This is the name that's used to determine which dumper should be used.
)
->addTag('translation.dumper', array('alias' => 'json'));
.. seealso::
Learn how to :ref:`dump to custom formats <components-translation-custom-dumper>`
in the components section.
.. _reference-dic-tags-twig-extension:
twig.extension
Expand Down

0 comments on commit efc1436

Please sign in to comment.