Skip to content

[Translation][Validator] Mention symfony/translation #15017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions validation/translations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ If you're using validation constraints with the Form component, you can translat
the error messages by creating a translation resource for the
``validators`` :ref:`domain <translation-resource-locations>`.

.. note::

In order to translate the error message, you should have installed the
symfony/translation component with Composer.

To start, suppose you've created a plain-old-PHP object that you need to
use somewhere in your application::

Expand Down Expand Up @@ -93,7 +98,7 @@ Now, create a ``validators`` catalog file in the ``translations/`` directory:

.. code-block:: xml

<!-- translations/validators.en.xlf -->
<!-- translations/validators/validators.en.xlf -->
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
Expand All @@ -108,12 +113,12 @@ Now, create a ``validators`` catalog file in the ``translations/`` directory:

.. code-block:: yaml

# translations/validators.en.yaml
# translations/validators/validators.en.yaml
author.name.not_blank: Please enter an author name.

.. code-block:: php

// translations/validators.en.php
// translations/validators/validators.en.php
return [
'author.name.not_blank' => 'Please enter an author name.',
];
Expand Down