uam/twig-i18n-extension

0.2.9 2017-01-23 12:00 UTC

README

68747470733a2f2f7472617669732d63692e6f72672f756e697465642d617369616e2f747769672d6931386e2d657874656e73696f6e2e7376673f6272616e63683d6d6173746572

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.