Twig Intl-extra: format_currency function not working with default locale on Symfony 5

Trying to use Twig Intl extra functions without passing arguments (expecting function get default locale).

If I pass ‘EUR’ argument to format_currency filter, it works perfectly:

{{ item.itemPrice|format_currency('EUR') }}

{# returns 10 € #}

If I don’t pass any argument, Twig documentation says: “By default, the filter uses the current locale”, but I’m getting this error:

Too few arguments to function TwigExtraIntlIntlExtension::formatCurrency(), 1 passed in […]/var/cache/dev/twig/[…].php on line 338 and at least 2 expected

I’ve configured Twig Intl-extra as a service on Symfony 5


        autowire: true      
        autoconfigure: true
        resource: '../vendor/twig/intl-extra/src/*'
        tags: ['twig.extension']


    default_locale: es_ES

Any idea for solving this issue?

Thank you very much!

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *