bitexpert/silex-twig-translation

This package is abandoned and no longer maintained. No replacement package was suggested.

Allows to use Symfony/Translation within a Silex / Twig application.

dev-master 2012-03-24 22:11 UTC

This package is not auto-updated.

Last update: 2019-02-20 17:12:26 UTC


README

README
======

What is Silex Twig Translation Extension?
----------------

The Silex Twig Translation Extension as the name implies is an extension for
the Twig templating engine allowing to use Symfony/Translation within the
Twig templates of an Silex powered application.

Requirements
----------------

You will need a working Silex + Symfony/Translation + Twig application.

Setup Symfony/Translation provider:
	$app->register(new Silex\Provider\TranslationServiceProvider(), array(
		'locale_fallback'        => 'en',
		'translation.class_path' => 'vendor/symfony/src',
	));
	$app['translator.messages'] = array(
		'en' => 'locales/en.yml',
		'de' => 'locales/de.yml'
	);
	$app['translator.loader'] = new Symfony\Component\Translation\Loader\YamlFileLoader();

Setup Twig:
	$app->register(new Silex\Provider\TwigServiceProvider(), array(
		'twig.path'       => __DIR__.'/views',
		'twig.class_path' => __DIR__.'/vendor/twig/lib'
		)
	));

Register silex-twig-extension:
	$app['twig']->addExtension(new bitExpert_Silex_Twig_Translation_Extension());

How to use?
----------------

Example: {% translate my_translation_key %}

Will pass my_translation_key to Symfony/Translation and render the result within
the twig template.