coolshop / cool-sonata-translation-bundle
集成翻译到sonata管理后台
2.0.4
2016-11-04 13:09 UTC
Requires
- php: >=5.3.0
- sonata-project/admin-bundle: *
- symfony/framework-bundle: >=2.1
README
CoolSonataTranslationBundle是一个用于管理您的Symfony翻译并存储到数据库中的组件。通过Ibrows,可以与Sonata Admin集成。
安装
在您的composer.json文件中添加以下行
{
"require": {
"coolshop/cool-sonata-translation-bundle" : "^2.0",
}
}
要开始使用该组件,在应用程序的kernel类中注册CoolSonataTranslationBundle
<php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Coolshop\CoolSonataTranslationBundle\CoolSonataTranslationBundle(),
);
)
配置
app/config/config.yml
cool_sonata_translation:
defaultDomain: messages
editable:
mode: inline # Mode of editable, can be popup or inline
type: textarea # Type of input. Can be text|textarea|select|date|checklist and more
emptytext: Empty # text to display on empty translations
placement: top # ingnored for inline mode
localeManager: '@cool_sonata_translation.locale_manager.sonatapage' #service that handles the locale available. Could be an array of locale (eg. localeManager: ['en', 'fr', 'es', 'de'])
driver: orm # Only ORM available at the moment.
database:
entity_manager: # if not specified will use default. This way you could handle translations with a separate EM.
使用
设置翻译表
./app/console doctrine:schema:update --force
为了在管理面板中显示一些键,您必须首先导入翻译文件。这通过一个命令完成
./app/console cool:translations:import [-c]
此命令还具有"-c"选项,因此您可以在导入之前先清空数据库。如果您的表已经填充,这可能对较大的导入稍微快一些。
生成模拟翻译文件或使用配置
./app/console asm:translations:dummy
由于TranslationLoader基于文件,因此您必须为想要使用翻译数据库的每种语言创建空文件,如"messages.en_US.db"。这些文件将放置在app/Resources/translations/*
注意:每次您在数据库中修改翻译时,都必须清除缓存以使用新的翻译。
./app/console cache:clear
待办事项:从管理面板中使清除缓存成为可能。
Sonata Admin集成
要将组件包含在管理仪表板中,请将“group.translation”组添加到仪表板
# app/config/config.yml
sonata_admin:
dashboard:
groups:
group.translation:
label: Translation
items: ~
就是这样!来Coolshop说一声“嗨”吧!