salim/sonata-translation-bundle

将Lexik翻译集成到Sonata管理后台

1.1.7 2018-02-27 14:40 UTC

README

SonataTranslationBundle是将LexikTranslationBundle集成到SonataAdminBundle中。

image

安装

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

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

要开始使用该包,请在您的应用程序的kernel类中注册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: ~ 

关于此就没有更多可说的了 ;).