Add twig/extensions to allow Twig dates translation

Client code can now use

`{{ a_date|localizeddate('long', 'short', grav.language.getLanguage) }}`
This commit is contained in:
Flavio Copes
2016-03-31 14:48:30 +02:00
parent 7158dd9beb
commit 810deb4105
2 changed files with 7 additions and 1 deletions

View File

@@ -26,7 +26,8 @@
"maximebf/debugbar": "~1.10",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-curl": "*"
"ext-curl": "*",
"twig/extensions": "^1.3"
},
"require-dev": {
"codeception/codeception": "^2.1",

View File

@@ -144,6 +144,11 @@ class Twig
}
$this->twig->addExtension(new TwigExtension());
// enable the Intl Twig extension if translations are enabled
if (count($config->get('system.languages.supported', [])) > 0) {
$this->twig->addExtension(new \Twig_Extensions_Extension_Intl());
}
$this->grav->fireEvent('onTwigExtensions');
// Set some standard variables for twig