How to make a Twig date translatable

symfony, twig

Solution

or use the The Intl Extension :

{{ "now"|localizeddate('none', 'none', app.request.locale, "Europe/Paris", "cccc d MMMM Y") }}

Will give you something like :

jeudi 25 février 2016

To enable with symfony 2, add to composer :

composer require twig/extensions

And activate filters with service :

services:
    twig.extension.intl:
        class: Twig_Extensions_Extension_Intl
        tags:
            - { name: twig.extension }

Problem

I am displaying a DateTime object in twig like this: ``` <td>{{ transaction.getDate|date("F - d - Y") }}</td> ``` Now I want the month to be translatable, For example `April - 20 - 2012` should be displayed as: `Avril - 20 - 2012` Can I do this? If so, how? I am working on Symfony2.

Original source