Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall 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 deletionsbook/translation.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 DownExpand 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 DownExpand 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp