Skip to content

Commit 511c418

Browse files
xabbuhdaFish
authored and
daFish
committed
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.
1 parent 396f94f commit 511c418

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

components/translation/custom_formats.rst

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ message. A translation file would look like this:
1818
(goodbye)(au revoir)
1919
(hello)(bonjour)
2020
21+
.. _components-translation-custom-loader:
22+
2123
Creating a Custom Loader
2224
------------------------
2325

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

6668
It will print *"accueil"*.
6769

70+
.. _components-translation-custom-dumper:
71+
6872
Creating a Custom Dumper
6973
------------------------
7074

reference/dic_tags.rst

+9-24
Original file line numberDiff line numberDiff line change
@@ -1040,32 +1040,12 @@ translation.loader
10401040
**Purpose**: To register a custom service that loads translations
10411041
10421042
By default, translations are loaded from the filesystem in a variety of different
1043-
formats (YAML, XLIFF, PHP, etc). If you need to load translations from some
1044-
other source, first create a class that implements the
1045-
:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface::
1043+
formats (YAML, XLIFF, PHP, etc).
10461044
1047-
// src/Acme/MainBundle/Translation/MyCustomLoader.php
1048-
namespace Acme\MainBundle\Translation;
1049-
1050-
use Symfony\Component\Translation\Loader\LoaderInterface;
1051-
use Symfony\Component\Translation\MessageCatalogue;
1052-
1053-
class MyCustomLoader implements LoaderInterface
1054-
{
1055-
public function load($resource, $locale, $domain = 'messages')
1056-
{
1057-
$catalogue = new MessageCatalogue($locale);
1058-
1059-
// some how load up some translations from the "resource"
1060-
// then set them into the catalogue
1061-
$catalogue->set('hello.world', 'Hello World!', $domain);
1062-
1063-
return $catalogue;
1064-
}
1065-
}
1045+
.. seealso::
10661046
1067-
Your custom loader's ``load`` method is responsible for returning a
1068-
:Class:`Symfony\\Component\\Translation\\MessageCatalogue`.
1047+
Learn how to :ref:`load custom formats <components-translation-custom-loader>`
1048+
in the components section.
10691049
10701050
Now, register your loader as a service and tag it with ``translation.loader``:
10711051
@@ -1257,6 +1237,11 @@ This is the name that's used to determine which dumper should be used.
12571237
)
12581238
->addTag('translation.dumper', array('alias' => 'json'));
12591239
1240+
.. seealso::
1241+
1242+
Learn how to :ref:`dump to custom formats <components-translation-custom-dumper>`
1243+
in the components section.
1244+
12601245
.. _reference-dic-tags-twig-extension:
12611246
12621247
twig.extension

0 commit comments

Comments
 (0)