ibrows/sonata-translation-bundle

Lexik翻译集成到Sonata管理后台

安装次数: 69,501

依赖: 1

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 2

开放问题: 1

类型:symfony-bundle

1.1.1 2015-07-03 09:55 UTC

README

SonataTranslationBundle是将LexikTranslationBundle集成到SonataAdminBundle中。

image

安装

在您的composer.json中添加以下行

{
    "require": {
		"ibrows/sonata-translation-bundle" : "dev-master",
    }
}

要开始使用此包,请在应用程序的内核类中注册SonataTranslationBundle和LexikTranslationBundle

<php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
		new Lexik\Bundle\TranslationBundle\LexikTranslationBundle(),
		new Ibrows\SonataTranslationBundle\IbrowsSonataTranslationBundle(),
    );
)

配置

SonataTranslationBundle

无需初始配置。

但是,您可以配置一些选项来编辑外观。以下为默认配置:

# app/config/config.yml
ibrows_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

LexikTranslationBundle

最小配置包括

# app/config/config.yml
lexik_translation:
    fallback_locale: en      # (required) default locale to use
    managed_locales: [en]    # (required) locales that the bundle have to manage

有关其他配置选项,请参阅官方文档

为了在管理面板中显示一些键,您必须首先导入翻译文件。这可以通过LexikTranslationBundle提供的命令来完成。

./app/console lexik:translations:import [bundleName] [--cache-clear] [--force] [--globals]

请再次参考官方文档以获取更多信息。

使用方法

要将此包包含在管理仪表板中,请将“group.translation”组添加到仪表板

# app/config/config.yml
sonata_admin:
    dashboard:
        groups:
            group.translation:
                label: Translation
                items: ~ 

关于这一点,就这么多(;)。