The Twig Extensions library contains a number of useful extensions for Twig. With the release of version 1.2.0, the localizedcurrency filter has been added to the Intl extension. As the name suggests, this filter will format a number based on the current locale. For this, the PHP class NumberFormatter .
Using
This filter is very easy to use. The only required argument for the filter is the three-digit currency code ISO 4217 . For example, to display an amount of 27.99 euros, use the following line of code:
{{ price|localizedcurrency('EUR') }}
Depending on the locale, different results will be displayed:
€27.99 if the locale is set to en27,99 € if the locale is set to fr€ 27,99 If locale is set to nl
Language Installation / Setup
Instructions for installing the Intl extension can be found in this separate answer .
Nic Wortel Feb 09 '15 at 12:41 2015-02-09 12:41
source share