bitexpert/silex-twig-translation
Composer 安装命令:
composer require bitexpert/silex-twig-translation
包简介
Allows to use Symfony/Translation within a Silex / Twig application.
关键字:
README 文档
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.
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache
- 更新时间: 2012-03-24