blob: 84a048ed52cb947a9f7f6ae3cc8e1a75772afc94 [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001``currency_symbol``
2===================
3
4The ``currency_symbol`` filter returns the currency symbol given its three-letter
5code:
6
7.. code-block:: twig
8
9 {# #}
10 {{ 'EUR'|currency_symbol }}
11
12 {# ¥ #}
13 {{ 'JPY'|currency_symbol }}
14
15By default, the filter uses the current locale. You can pass it explicitly:
16
17.. code-block:: twig
18
19 {# ¥ #}
20 {{ 'JPY'|currency_symbol('fr') }}
21
22.. note::
23
24 The ``currency_symbol`` 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
44Arguments
45---------
46
47* ``locale``: The locale