kluev-andrew/sonata-admin-jms-translations

将JMSTranslationBundle添加到SonataAdminBundle

2.3.x-dev 2014-05-16 04:32 UTC

This package is auto-updated.

Last update: 2024-08-29 03:41:52 UTC


README

功能

  • 集成JMSTranslationBundle与SonataAdminBundle
  • 提供添加翻译消息表单
  • 从Web界面中失效缓存
  • 从Web界面中删除翻译

安装

步骤 1: 使用composer下载KASonataAdminJMSTranslationBundle

在composer.json中添加KASonataAdminJMSTranslationBundle

对于Sonata admin <=2.2使用

{
    "require": {
        "kluev-andrew/sonata-admin-jms-translations": "dev-master"
    }
}

对于Sonata admin >=2.3使用

{
    "require": {
        "kluev-andrew/sonata-admin-jms-translations": ">=2.3"
    }
}

现在通过运行以下命令告诉composer下载bundle

$ php composer.phar update kluev-andrew/sonata-admin-jms-translations

Composer会将bundle安装到您的项目的KA/SonataAdminJMSTranslationBundle目录中。

步骤 2: 启用bundle

在kernel中启用bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\DiExtraBundle\JMSDiExtraBundle($this),
        new JMS\AopBundle\JMSAopBundle(),
        new JMS\TranslationBundle\JMSTranslationBundle(),
        new KA\SonataAdminJMSTranslationBundle\KASonataAdminJMSTranslationBundle(),
        // ...
    );
}

步骤 3: 导入KASonataAdminJMSTranslationBundle路由

在YAML中类似

# app/config/routing.yml

admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin

KASonataAdminJMSTranslationBundle_ui:
    resource: @KASonataAdminJMSTranslationBundle/Controller/
    type:     annotation
    prefix:   /admin/translations

步骤 4: 覆盖您的Sonata Admin布局

a) 设置配置

# app/config/config.yml

sonata_admin:
    templates:
        # default global templates
        layout:  AcmeBundle:CRUD:layout.html.twig

b) 创建模板

{# AcmeBundle/Resources/views/CRUD/layout.html.twig #}

{% extends 'SonataAdminBundle::standard_layout.html.twig' %}

{% block side_bar_after_nav %}
    <ul class="sidebar-menu">
        <li>
            <a href="{{ path('jms_translation_index') }}">
                <i class="fa fa-angle-double-right"></i>
                <span>JMSTranslations</span>
            </a>
        </li>
    </ul>
{% endblock %}

步骤 5

不要忘记配置您的SonataAdminBundleJMSTranslationBundle