Version 1
[yaffs-website] / web / core / modules / system / tests / modules / twig_theme_test / templates / twig_theme_test.trans.html.twig
1 {# Test trans tag with string argument. #}
2 <div>
3   {% trans 'Hello sun.' %}
4 </div>
5
6 {# Test trans tag with string argument and context #}
7 <div>
8   {% trans 'Hello sun.' with {'context': 'Lolspeak'} %}
9 </div>
10
11 {# Test trans filter. #}
12 <div>
13   {{ 'Hello Earth.'|trans }}
14 </div>
15
16 {# Test trans tag with text content. #}
17 <div>
18   {% trans %}
19     Hello moon.
20   {% endtrans %}
21 </div>
22
23 {# Test trans/plural tag where count = 1. #}
24 <div>
25   {% set count = 1 %}
26   {% trans %}
27     Hello star.
28   {% plural count %}
29     Hello {{ count }} stars.
30   {% endtrans %}
31 </div>
32
33 {# Test trans/plural tag where count = 2. #}
34 <div>
35   {% set count = 2 %}
36   {% trans %}
37     Hello star.
38   {% plural count %}
39     Hello {{ count }} stars.
40   {% endtrans %}
41 </div>
42
43 {# Test trans tag with different filters applied to tokens. #}
44 {% set string = '&"<>' %}
45 <div>
46   {% trans %}
47     Escaped: {{ string }}
48   {% endtrans %}
49 </div>
50 <div>
51   {% trans %}
52     Placeholder: {{ string|placeholder }}
53   {% endtrans %}
54 </div>
55
56 {# Test trans tag with complex tokens. #}
57 {% set token = {'name': 'complex token', 'numbers': '12345', 'bad_text': '&"<>' } %}
58 {% set count = token|length %}
59 <div>
60   {% trans %}
61     This {{ token.name }} has a length of: {{ count }}. It contains: {{ token.numbers|placeholder }} and {{ token.bad_text }}.
62   {% endtrans %}
63 </div>
64
65 {# Test trans tag but with a context only msgid. #}
66 <div>
67   {% trans %}
68     I have context.
69   {% endtrans %}
70 </div>
71
72 {# Test trans tag with context. #}
73 <div>
74   {% trans with {'context': 'Lolspeak'} %}
75     I have context.
76   {% endtrans %}
77 </div>
78
79 {# Test trans tag with a specified language. #}
80 <div>
81   {% trans with {'langcode': 'zz'} %}
82     Hello new text.
83   {% endtrans %}
84 </div>
85
86 {# Test trans tag with context and a specified language. #}
87 <div>
88   {% trans with {'context': 'Lolspeak', 'langcode': 'zz'} %}
89     Hello new text.
90   {% endtrans %}
91 </div>
92
93 {# Tests that https://www.drupal.org/node/2489024 doesn't happen without twig debug. #}
94 <div>
95   {% trans %}
96     Number I never remember: ' . print(pi()) . '
97   {% endtrans %}
98 </div>