@@ -9,27 +9,13 @@ Twig Templates
9
9
Using Twig Tags
10
10
~~~~~~~~~~~~~~~
11
11
12
- Symfony provides specialized Twig tags ( ``trans `` and `` transchoice ``) to
13
- help with message translation of *static blocks of text *:
12
+ Symfony provides a specialized Twig tag ``trans `` to help with message
13
+ translation of *static blocks of text *:
14
14
15
15
.. code-block :: twig
16
16
17
17
{% trans %}Hello %name%{% endtrans %}
18
18
19
- {% transchoice count %}
20
- {0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples
21
- {% endtranschoice %}
22
-
23
- The ``transchoice `` tag automatically gets the ``%count% `` variable from
24
- the current context and passes it to the translator. This mechanism only
25
- works when you use a placeholder following the ``%var% `` pattern.
26
-
27
- .. deprecated :: 4.2
28
-
29
- The ``transchoice `` tag is deprecated since Symfony 4.2 and will be
30
- removed in 5.0. Use the :doc: `ICU MessageFormat </translation/message_format >` with
31
- the ``trans `` tag instead.
32
-
33
19
.. caution ::
34
20
35
21
The ``%var% `` notation of placeholders is required when translating in
@@ -48,34 +34,19 @@ You can also specify the message domain and pass some additional variables:
48
34
49
35
{% trans with {'%name%': 'Fabien'} from 'app' into 'fr' %}Hello %name%{% endtrans %}
50
36
51
- {% transchoice count with {'%name%': 'Fabien'} from 'app' %}
52
- {0} %name%, there are no apples|{1} %name%, there is one apple|]1,Inf[ %name%, there are %count% apples
53
- {% endtranschoice %}
54
-
55
37
.. _translation-filters :
56
38
57
39
Using Twig Filters
58
40
~~~~~~~~~~~~~~~~~~
59
41
60
- The ``trans `` and ``transchoice `` filters can be used to translate *variable
61
- texts * and complex expressions:
42
+ The ``trans `` filter can be used to translate *variable texts * and complex expressions:
62
43
63
44
.. code-block :: twig
64
45
65
46
{{ message|trans }}
66
47
67
- {{ message|transchoice(5) }}
68
-
69
48
{{ message|trans({'%name%': 'Fabien'}, 'app') }}
70
49
71
- {{ message|transchoice(5, {'%name%': 'Fabien'}, 'app') }}
72
-
73
- .. deprecated :: 4.2
74
-
75
- The ``transchoice `` filter is deprecated since Symfony 4.2 and will be
76
- removed in 5.0. Use the :doc: `ICU MessageFormat </translation/message_format >` with
77
- the ``trans `` filter instead.
78
-
79
50
.. tip ::
80
51
81
52
Using the translation tags or filters have the same effect, but with
@@ -116,8 +87,3 @@ The translator service is accessible in PHP templates through the
116
87
117
88
<?= $view['translator']->trans('Symfony is great') ?>
118
89
119
- <?= $view['translator']->transChoice(
120
- '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples',
121
- 10,
122
- ['%count%' => 10]
123
- ) ?>
0 commit comments