Skip to content

Remove usages of transChoice() method for Symfony 5.0 #12957

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
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ Translation
~~~~~~~~~~~

If you're using the Twig integration with one of the default form theme files
(e.g. ``form_div_layout.html.twig``), there are 2 Twig filters (``trans``
and ``transChoice``) that are used for translating form labels, errors, option
(e.g. ``form_div_layout.html.twig``), there is a Twig filter (``trans``)
that is used for translating form labels, errors, option
text and other strings.

To add these Twig filters, you can either use the built-in
To add the ``trans`` Twig filter, you can either use the built-in
:class:`Symfony\\Bridge\\Twig\\Extension\\TranslationExtension` that integrates
with Symfony's Translation component, or add the 2 Twig filters yourself,
with Symfony's Translation component, or add the Twig filter yourself,
via your own Twig extension.

To use the built-in integration, be sure that your project has Symfony's
Expand Down Expand Up @@ -281,7 +281,7 @@ to your ``Twig\Environment`` instance::
'en'
);

// adds the TranslationExtension (gives us trans and transChoice filters)
// adds the TranslationExtension (it gives us trans filter)
$twig->addExtension(new TranslationExtension($translator));

$formFactory = Forms::createFormFactoryBuilder()
Expand Down
3 changes: 1 addition & 2 deletions components/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ To actually translate the message, the Translator uses the following process:
not, the translator returns the original message.

You start this process by calling
:method:`Symfony\\Component\\Translation\\Translator::trans` or
:method:`Symfony\\Component\\Translation\\Translator::transChoice`. Then, the
:method:`Symfony\\Component\\Translation\\Translator::trans`. Then, the
Translator looks for the exact string inside the appropriate message catalog
and returns it (if it exists).

Expand Down
22 changes: 0 additions & 22 deletions components/translation/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,28 +166,6 @@ use for translation::
'fr_FR'
);

$translator->transChoice(
'{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
10,
[],
'messages',
'fr_FR'
);

.. note::

Starting from Symfony 3.2, the third argument of ``transChoice()`` is
optional when the only placeholder in use is ``%count%``. In previous
Symfony versions you needed to always define it::

$translator->transChoice(
'{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
10,
['%count%' => 10],
'messages',
'fr_FR'
);

.. _retrieving-the-message-catalogue:

Retrieving the Message Catalog
Expand Down