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

Commit00a962a

Browse files
Changing translations examples to not use single character variable name
1 parentb84abc6 commit00a962a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

‎book/translation.rst‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ for example, that you're translating a simple message from inside a controller::
100100

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

105-
return new Response($t);
105+
return new Response($translated);
106106
}
107107

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

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

181-
return new Response($t);
181+
return new Response($translated);
182182
}
183183

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

193193
public function indexAction($name)
194194
{
195-
$t = $this->get('translator')->trans(
195+
$translated = $this->get('translator')->trans(
196196
'Hello %name%',
197197
array('%name%' => $name)
198198
);
199199

200-
return new Response($t);
200+
return new Response($translated);
201201
}
202202

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

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

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

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

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

773773
..code-block::jinja

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp