4
4
Translations
5
5
============
6
6
7
- The term "internationalization" (often abbreviated `i18n `_) refers to the process
8
- of abstracting strings and other locale-specific pieces out of your application
9
- and into a layer where they can be translated and converted based on the user's
10
- locale (i.e. language and country). For text, this means wrapping each with a
11
- function capable of translating the text (or "message") into the language of
12
- the user::
7
+ The term "internationalization" (often abbreviated `i18n `_) refers to the
8
+ process of abstracting strings and other locale-specific pieces out of your
9
+ application and into a layer where they can be translated and converted based
10
+ on the user's locale (i.e. language and country). For text, this means
11
+ wrapping each with a function capable of translating the text (or "message")
12
+ into the language of the user::
13
13
14
14
// text will *always* print out in English
15
15
echo 'Hello World';
@@ -21,10 +21,10 @@ the user::
21
21
.. note ::
22
22
23
23
The term *locale * refers roughly to the user's language and country. It
24
- can be any string that your application uses to manage translations
25
- and other format differences (e.g. currency format). The
26
- ` ISO639-1 `_ *language * code, an underscore (``_ ``), then the `ISO3166 Alpha-2 `_ * country *
27
- code (e.g. ``fr_FR `` for French/France) is recommended.
24
+ can be any string that your application uses to manage translations and
25
+ other format differences (e.g. currency format). The ` ISO639-1 `_
26
+ *language * code, an underscore (``_ ``), then the `ISO3166 Alpha-2 `_
27
+ * country * code (e.g. ``fr_FR `` for French/France) is recommended.
28
28
29
29
In this chapter, you'll learn how to use the Translation component in the
30
30
Symfony2 framework. Read the
@@ -33,7 +33,8 @@ the Translator. Overall, the process has several common steps:
33
33
34
34
#. Enable and configure Symfony's Translation component;
35
35
36
- #. Abstract strings (i.e. "messages") by wrapping them in calls to the ``Translator ``;
36
+ #. Abstract strings (i.e. "messages") by wrapping them in calls to the
37
+ ``Translator `` (learn about this in ":doc: `/components/translation/usage `");
37
38
38
39
#. Create translation resources for each supported locale that translate
39
40
each message in the application;
@@ -132,13 +133,14 @@ Using the Translation inside Controllers
132
133
----------------------------------------
133
134
134
135
When you want to use translation inside controllers, you need to get the
135
- ``translator `` service and use ``trans `` or ``transChoice ``::
136
+ ``translator `` service and use
137
+ :method: `Symfony\\ Component\\ Translation\\ Translator::trans ` or
138
+ :method: `Symfony\\ Component\\ Translation\\ Translator::transChoice `::
136
139
137
140
// src/Acme/DemoBundle/Controller/DemoController.php
138
141
namespace Amce\DemoBundle\Controller;
139
142
140
143
// ...
141
-
142
144
class DemoController extends Controller
143
145
{
144
146
public function indexAction()
@@ -541,7 +543,8 @@ steps:
541
543
542
544
* Abstract messages in your application by wrapping each in either the
543
545
:method: `Symfony\\ Component\\ Translation\\ Translator::trans ` or
544
- :method: `Symfony\\ Component\\ Translation\\ Translator::transChoice ` methods;
546
+ :method: `Symfony\\ Component\\ Translation\\ Translator::transChoice ` methods
547
+ (learn about this in ":doc: `/components/translation/usage `");
545
548
546
549
* Translate each message into multiple locales by creating translation message
547
550
files. Symfony2 discovers and processes each file because its name follows
0 commit comments