Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9790975

Browse filesBrowse files
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 2319d6a commit 9790975
Copy full SHA for 9790975

File tree

Expand file treeCollapse file tree

2 files changed

+13
-24
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-24
lines changed

‎components/translation/custom_formats.rst

Copy file name to clipboardExpand all lines: components/translation/custom_formats.rst
+4Lines changed: 4 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: reference/dic_tags.rst
+9-24Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,32 +1029,12 @@ translation.loader
10291029
**Purpose**: To register a custom service that loads translations
10301030
10311031
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).
10351033
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::
10551035
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.
10581038
10591039
Now, register your loader as a service and tag it with ``translation.loader``:
10601040
@@ -1252,6 +1232,11 @@ This is the name that's used to determine which dumper should be used.
12521232
)
12531233
->addTag('translation.dumper', array('alias' => 'json'));
12541234
1235+
.. seealso::
1236+
1237+
Learn how to :ref:`dump to custom formats <components-translation-custom-dumper>`
1238+
in the components section.
1239+
12551240
.. _reference-dic-tags-twig-extension:
12561241
12571242
twig.extension

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.