Skip to content

Commit bfd78b3

Browse files
committed
Improvements based on comments
1 parent 105a168 commit bfd78b3

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

components/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130

131131
* :doc:`/components/translation/introduction`
132132
* :doc:`/components/translation/usage`
133+
* :doc:`/components/translation/custom_formats`
133134

134135
* :doc:`/components/yaml/index`
135136

components/translation/custom_formats.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. index::
22
single: Translation; Custom formats
33

4-
Custom formats
4+
Custom Formats
55
==============
66

77
Sometimes, you need to deal with custom formats for translation files. The
@@ -10,19 +10,23 @@ loader (to load translations) and, optionally, a dumper (to dump translations).
1010

1111
Let's imagine you have a custom format where translation messages are defined
1212
using one line for each translation and parenthesis to wrap the key and the
13-
message. A translation file would look like this::
13+
message. A translation file would look like this:
14+
15+
.. code-block:: text
1416
1517
(welcome)(Bienvenido)
1618
(goodbye)(Adios)
1719
(hello)(Hola)
1820
21+
Custom Loader
22+
-------------
23+
1924
To define a custom loader able to read this kind of files, you must create a
2025
new class that implements the
21-
:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface,
22-
which defines a
26+
:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface`. The
2327
:method:`Symfony\\Component\\Translation\\Loader\\LoaderInterface::load`
24-
method. In the loader, this method will get a filename and parse it to create an
25-
array. Then, it will create the catalog that will be returned::
28+
method will get a filename and parse it into an array. Then, it will
29+
create the catalogue that will be returned::
2630

2731
use Symfony\Component\Translation\MessageCatalogue;
2832
use Symfony\Component\Translation\Loader\LoaderInterface;
@@ -59,8 +63,11 @@ Once created, it can be used as any other loader::
5963

6064
It will print *"Bienvenido"*.
6165

62-
It is also possible to create a custom dumper for your format. To do so,
63-
a new class implementing the
66+
Custom Dumper
67+
-------------
68+
69+
It is also possible to create a custom dumper for your format, useful when using
70+
the extraction commands. To do so, a new class implementing the
6471
:class:`Symfony\\Component\\Translation\\Dumper\\DumperInterface`
6572
interface must be created.
6673
To write the dump contents into a file, extending the

components/translation/introduction.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ The Translation component uses Loader classes to load catalogs. You can load
6262
multiple resources for the same locale, which will then be combined into one
6363
catalog.
6464

65-
The component comes with some default Loaders and you can
66-
:doc:`create your own Loader too</components/translation/custom_formats>`. The
65+
The component comes with some default loaders and you can
66+
:doc:`create your own Loader too </components/translation/custom_formats>`. The
6767
default loaders are:
6868

6969
* :class:`Symfony\\Component\\Translation\\Loader\\ArrayLoader` - to load

0 commit comments

Comments
 (0)