Skip to content

Commit f84c8b3

Browse files
committed
Merge branch '4.4' into 5.2
* 4.4: [Validator][Translation] Mention symfony/translation
2 parents e8a76fa + a254b85 commit f84c8b3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

validation/translations.rst

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
How to Translate Validation Constraint Messages
55
===============================================
66

7-
If you're using validation constraints with the Form component, you can translate
8-
the error messages by creating a translation resource for the
9-
``validators`` :ref:`domain <translation-resource-locations>`.
7+
The validation constraints used in forms can translate their error messages by
8+
creating a translation resource for the ``validators``
9+
:ref:`translation domain <translation-resource-locations>`.
1010

11-
To start, suppose you've created a plain-old-PHP object that you need to
12-
use somewhere in your application::
11+
First of all, install the Symfony translation component (if it's not already
12+
installed in your application) running the following command:
13+
14+
.. code-block:: terminal
15+
16+
$ composer require symfony/translation
17+
18+
Suppose you've created a plain-old-PHP object that you need to use somewhere in
19+
your application::
1320

1421
// src/Entity/Author.php
1522
namespace App\Entity;
@@ -106,7 +113,7 @@ Now, create a ``validators`` catalog file in the ``translations/`` directory:
106113

107114
.. code-block:: xml
108115
109-
<!-- translations/validators.en.xlf -->
116+
<!-- translations/validators/validators.en.xlf -->
110117
<?xml version="1.0"?>
111118
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
112119
<file source-language="en" datatype="plaintext" original="file.ext">
@@ -121,12 +128,12 @@ Now, create a ``validators`` catalog file in the ``translations/`` directory:
121128
122129
.. code-block:: yaml
123130
124-
# translations/validators.en.yaml
131+
# translations/validators/validators.en.yaml
125132
author.name.not_blank: Please enter an author name.
126133
127134
.. code-block:: php
128135
129-
// translations/validators.en.php
136+
// translations/validators/validators.en.php
130137
return [
131138
'author.name.not_blank' => 'Please enter an author name.',
132139
];

0 commit comments

Comments
 (0)