Twig Extensions 1.2 released with two new i18n filters

Internationalisation filters in Twig.

Twig Extensions 1.2 was silently released a few days ago.

This version includes 2 new internationalisation filters I have contributed to (based on previous Bertrand Zuchuat work):

  • one for localised numbers
  • one for localised currencies.

Localised numbers:

{{ product.quantity|localizednumber }}

Localised currencies:

{{ product.price|localizedcurrency('EUR') }}

They both use the standard PHP NumberFormatter class.

Example: {{ 1435.87|localizednumber }} will render:

  • 1 435,87 if fr_FR is the current locale
  • 1,435.87 if en_US is the current locale.

Find out more about these filters and their options on the updated Twig Intl extension documentation page.