blob: 434b0bda7a125385216d674507b0be649a4099e7 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``country_name``
2================
3
4The ``country_name`` filter returns the country name given its ISO-3166
5two-letter code:
6
7.. code-block:: twig
8
9 {# France #}
10 {{ 'FR'|country_name }}
11
12By default, the filter uses the current locale. You can pass it explicitly:
13
14.. code-block:: twig
15
16 {# États-Unis #}
17 {{ 'US'|country_name('fr') }}
18
19.. note::
20
21 The ``country_name`` filter is part of the ``IntlExtension`` which is not
22 installed by default. Install it first:
23
24 .. code-block:: bash
25
26 $ composer require twig/intl-extra
27
28 Then, on Symfony projects, install the ``twig/extra-bundle``:
29
30 .. code-block:: bash
31
32 $ composer require twig/extra-bundle
33
34 Otherwise, add the extension explicitly on the Twig environment::
35
36 use Twig\Extra\Intl\IntlExtension;
37
38 $twig = new \Twig\Environment(...);
39 $twig->addExtension(new IntlExtension());
40
41Arguments
42---------
43
44* ``locale``: The locale