Skip to content

Changing translations examples to not use single character variable name #2536

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
May 4, 2013
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
20 changes: 10 additions & 10 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ for example, that you're translating a simple message from inside a controller::

public function indexAction()
{
$t = $this->get('translator')->trans('Symfony2 is great');
$translated = $this->get('translator')->trans('Symfony2 is great');

return new Response($t);
return new Response($translated);
}

When this code is executed, Symfony2 will attempt to translate the message
Expand Down Expand Up @@ -176,9 +176,9 @@ Sometimes, a message containing a variable needs to be translated::

public function indexAction($name)
{
$t = $this->get('translator')->trans('Hello '.$name);
$translated = $this->get('translator')->trans('Hello '.$name);

return new Response($t);
return new Response($translated);
}

However, creating a translation for this string is impossible since the translator
Expand All @@ -192,12 +192,12 @@ variable with a "placeholder"::

public function indexAction($name)
{
$t = $this->get('translator')->trans(
$translated = $this->get('translator')->trans(
'Hello %name%',
array('%name%' => $name)
);

return new Response($t);
return new Response($translated);
}

Symfony2 will now look for a translation of the raw message (``Hello %name%``)
Expand Down Expand Up @@ -380,9 +380,9 @@ Symfony2 will discover these files and use them when translating either
This example illustrates the two different philosophies when creating
messages to be translated::

$t = $translator->trans('Symfony2 is great');
$translated = $translator->trans('Symfony2 is great');

$t = $translator->trans('symfony2.great');
$translated = $translator->trans('symfony2.great');

In the first method, messages are written in the language of the default
locale (English in this case). That message is then used as the "id"
Expand Down Expand Up @@ -619,7 +619,7 @@ all the forms as a string separated by a pipe (``|``)::
To translate pluralized messages, use the
:method:`Symfony\\Component\\Translation\\Translator::transChoice` method::

$t = $this->get('translator')->transChoice(
$translated = $this->get('translator')->transChoice(
'There is one apple|There are %count% apples',
10,
array('%count%' => 10)
Expand Down Expand Up @@ -767,7 +767,7 @@ texts* and complex expressions:
Using the translation tags or filters have the same effect, but with
one subtle difference: automatic output escaping is only applied to
translations using a filter. In other words, if you need to be sure
that your translated is *not* output escaped, you must apply the
that your translated is *not* output escaped, you must apply the
``raw`` filter after the translation filter:

.. code-block:: jinja
Expand Down