bitexpert / silex-twig-translation
Allows to use Symfony/Translation within a Silex / Twig application.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 11
Forks: 0
Open Issues: 0
pkg:composer/bitexpert/silex-twig-translation
Requires
- silex/silex: 1.0.*
- symfony/config: 2.*
- symfony/translation: 2.*
- symfony/yaml: 2.*
- twig/twig: 1.*
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.