The Twig Intl Extension
You can use the Twig Intl Extension found in fabpot's official Twig extension repository.
It provides a localized date filter which can be used like this:
{{ date | localizeddate('full', 'none', app.request.locale ) }}
use app.request.locale
as third parameter for current locale or just 'sv'
.
Integration into your project
add the official extensions to your composer.json
using:
composer require twig/extensions:1.0.*@dev
composer update twig/extensions
config.yml
#enable intl extensions
services:
twig.extension.intl:
class: Twig_Extensions_Extension_Intl
tags:
- { name: twig.extension }
quick tip:
another handy extension is the Text extension providing truncate,...etc filters
services:
twig.extension.text:
class: Twig_Extensions_Extension_Text
tags:
- { name: twig.extension }
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…