@@ -1029,32 +1029,12 @@ translation.loader
1029
1029
**Purpose**: To register a custom service that loads translations
1030
1030
1031
1031
By default, translations are loaded from the filesystem in a variety of different
1032
- formats (YAML, XLIFF, PHP, etc). If you need to load translations from some
1033
- other source, first create a class that implements the
1034
- :class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface::
1032
+ formats (YAML, XLIFF, PHP, etc).
1035
1033
1036
- // src/Acme/MainBundle/Translation/MyCustomLoader.php
1037
- namespace Acme\MainBundle\Translation;
1038
-
1039
- use Symfony\Component\Translation\Loader\LoaderInterface;
1040
- use Symfony\Component\Translation\MessageCatalogue;
1041
-
1042
- class MyCustomLoader implements LoaderInterface
1043
- {
1044
- public function load($resource, $locale, $domain = 'messages')
1045
- {
1046
- $catalogue = new MessageCatalogue($locale);
1047
-
1048
- // some how load up some translations from the " resource"
1049
- // then set them into the catalogue
1050
- $catalogue->set('hello.world', 'Hello World!', $domain);
1051
-
1052
- return $catalogue;
1053
- }
1054
- }
1034
+ .. seealso::
1055
1035
1056
- Your custom loader's ``load`` method is responsible for returning a
1057
- :Class:`Symfony\\Component\\Translation\\MessageCatalogue` .
1036
+ Learn how to :ref:`load custom formats <components-translation-custom-loader>`
1037
+ in the components section .
1058
1038
1059
1039
Now, register your loader as a service and tag it with ``translation.loader``:
1060
1040
@@ -1252,6 +1232,11 @@ This is the name that's used to determine which dumper should be used.
1252
1232
)
1253
1233
->addTag('translation.dumper', array('alias' => 'json'));
1254
1234
1235
+ .. seealso::
1236
+
1237
+ Learn how to :ref:`dump to custom formats <components-translation-custom-dumper>`
1238
+ in the components section.
1239
+
1255
1240
.. _reference-dic-tags-twig-extension:
1256
1241
1257
1242
twig.extension
0 commit comments