pete31/sonata-translation-bundle

Lexik翻译集成到Sonata Admin

安装: 184

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v1.0.1 2020-02-08 12:55 UTC

This package is auto-updated.

Last update: 2024-09-08 23:52:33 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: ~ 

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