Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``country_name`` |
| 2 | ================ |
| 3 | |
| 4 | The ``country_name`` filter returns the country name given its ISO-3166 |
| 5 | two-letter code: |
| 6 | |
| 7 | .. code-block:: twig |
| 8 | |
| 9 | {# France #} |
| 10 | {{ 'FR'|country_name }} |
| 11 | |
| 12 | By 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 | |
| 41 | Arguments |
| 42 | --------- |
| 43 | |
| 44 | * ``locale``: The locale |