uam / twig-i18n-extension
Twig i18n extension
Installs: 22 946
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- symfony/intl: ^2.8||^3.0
- symfony/translation: ^2.8||^3.0
- twig/twig: ^1.24
Requires (Dev)
- fzaninotto/faker: ^1.5
- phpunit/phpunit: ^4.6||^5.4
README
The uam/twig-i18n-extension
package provides a Twig extension for internationalizing dates, numbers, etc.
Installation
Add the package to your project's composer.json
:
{ "require": { "uam/twig-i18n-extension": "dev-master", ... } }
Run composer install
or composer update
to install the package:
$ php composer.phar update
Usage
Add the extension to the Twig_Environment:
use UAM\Twig\Extension\I18n\I18nExtension; $twig = new Twig_Environment(...); $twig->addExtension(new I18nExtension());
Symfony2
To use the extension in a symfony2 app, use the built-in UAMTwigI18nBundle
:
Enable the bundle in your app's Appkernel:
# app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( ... new UAM\Twig\Extension\I18n\Bridge\Symfony\UAMTwigI18nBundle(), ... );
The bundle will automaticallty register the UAM\Twig\Extension\I18nExtension
as a twig extension.