Skip to content

Update translation.rst #9119

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

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 1 addition & 2 deletions components/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ The constructor of the ``Translator`` class needs one argument: The locale.
.. code-block:: php

use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;

$translator = new Translator('fr_FR', new MessageSelector());
$translator = new Translator('fr_FR');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can replace with :

new MessageFormatter();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh, I strongly disagree. My main reason being:

Neither the old MessageSelector nor the MessageFormatter appear in any of the texts surrounding the example and thus don't provide any value at all for the reader.

If the MessageFormatter were to be added, it would be helpful to provide the reader with some reason, opportunity or otherwise that can be gained by doing so. Since the text is targeted at developers wanting to include the Translator component, and the common use case described in the following texts don't include a MessageFormatter at all, I don't see the merits of adding a parameter that is not referenced at all.

I would agree, that the article could be improved by discussing the formatter parameter in some way, but this is way beyond the scope of this commit (and I would argue, that this would be going in some extra section)


.. note::

Expand Down