From 9790975d0c0081081d8fdd1c59603d567e94baf6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 18 Sep 2014 00:27:58 +0200 Subject: [PATCH] link translation DIC tags to components section The `translation.loader` and `translation.dumper` DIC tags link to the respective sections in the Translation component documentation. --- components/translation/custom_formats.rst | 4 +++ reference/dic_tags.rst | 33 +++++++---------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst index cf2d899e4d7..4378d249f86 100644 --- a/components/translation/custom_formats.rst +++ b/components/translation/custom_formats.rst @@ -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 ------------------------ @@ -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 ------------------------ diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index ffe098ce8ae..a746ef7ef86 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -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 ` + in the components section. Now, register your loader as a service and tag it with ``translation.loader``: @@ -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 ` + in the components section. + .. _reference-dic-tags-twig-extension: twig.extension