Matthias Andreas Benkard | 12a5735 | 2021-12-28 18:02:04 +0100 | [diff] [blame^] | 1 | ``currency_name`` |
| 2 | ================= |
| 3 | |
| 4 | The ``currency_name`` filter returns the currency name given its three-letter |
| 5 | code: |
| 6 | |
| 7 | .. code-block:: twig |
| 8 | |
| 9 | {# Euro #} |
| 10 | {{ 'EUR'|currency_name }} |
| 11 | |
| 12 | {# Japanese Yen #} |
| 13 | {{ 'JPY'|currency_name }} |
| 14 | |
| 15 | By default, the filter uses the current locale. You can pass it explicitly: |
| 16 | |
| 17 | .. code-block:: twig |
| 18 | |
| 19 | {# yen japonais #} |
| 20 | {{ 'JPY'|currency_name('fr_FR') }} |
| 21 | |
| 22 | .. note:: |
| 23 | |
| 24 | The ``currency_name`` filter is part of the ``IntlExtension`` which is not |
| 25 | installed by default. Install it first: |
| 26 | |
| 27 | .. code-block:: bash |
| 28 | |
| 29 | $ composer require twig/intl-extra |
| 30 | |
| 31 | Then, on Symfony projects, install the ``twig/extra-bundle``: |
| 32 | |
| 33 | .. code-block:: bash |
| 34 | |
| 35 | $ composer require twig/extra-bundle |
| 36 | |
| 37 | Otherwise, add the extension explicitly on the Twig environment:: |
| 38 | |
| 39 | use Twig\Extra\Intl\IntlExtension; |
| 40 | |
| 41 | $twig = new \Twig\Environment(...); |
| 42 | $twig->addExtension(new IntlExtension()); |
| 43 | |
| 44 | Arguments |
| 45 | --------- |
| 46 | |
| 47 | * ``locale``: The locale |