承接 ao/translation-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ao/translation-bundle

Composer 安装命令:

composer require ao/translation-bundle

包简介

Doctrine as symfony translation provider + a nice gui for editing translations.

README 文档

README

This bundle provides doctrine as translations storage and a nice web gui accessible from the profiler for easy translation.

Build Status

Features

  • All translation messages are automatically saved in the database (no extraction necessary)
  • Translation panel available in the Symfony web debug toolbar
  • Only messages used in current action are loaded from the database
  • Translations management backend available via SonataAdminBundle

Installation

Require vendor libraries

Require ao/translation-bundle & stof/doctrine-extensions-bundle in composer.json:

"require": {
  "symfony/symfony": "2.1.*",
  "_comment": "other packages",
  "stof/doctrine-extensions-bundle": "1.1.*@dev",
  "ao/translation-bundle": "1.0.*@dev"
}

Then install or update composer bundles with:

php composer.phar install

or

php composer.phar update

Add bundles to your application kernel

In app/AppKernel.php add:

// app/AppKernel.php
public function registerBundles()
{
    return array(
        //...
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
        new AO\TranslationBundle\AOTranslationBundle()
        //...
    );
}

Configure translator

# app/config/config.yml
# enable translation component
framework:
    translator: ~

# use AOTranslationBundle as translator
parameters:
    translator.class: AO\TranslationBundle\Translation\Translator

# configure locales avaliable for translation 
ao_translation:
    locales:
        en: ~
        de:
          label: German
        fr: ~

Configure doctrine extensions bundle

Timestampable behavior has to be enabled.

# app/config/config.yml
stof_doctrine_extensions:
    orm:
        default:
            timestampable: true

Update your db schema

If you use migrations:

app/console doctrine:migrations:diff
app/console doctrine:migrations:migrate

Otherwise:

app/console doctrine:schema:update

Add routing information

# app/config/routing.yml
ao_translation:
    resource: "@AOTranslationBundle/Controller/"
    type:     annotation
    prefix:   / 

Usage

Use translation methods like described in Symfony Translations documentation.

Translations panel

You can access translations panel by clicking on Translations in the web debug toolbar.

Translations web debug toolbar

Now you can edit all your translation messages. Message parameters can be inserted directly into translation by clicking on the link in Parameters (2) column. After you are done click the Save Translations button (1).

As the translator needs to know which messages are used in each action, it stores this relation in a cache table. Therefore, when a message is not used anymore it will still be visible in the translations panel. To clear the cached messages use the Reset action cache (3) button, which will clear the cache for current action. Alternatively use the Reset cache (4) button, which will clear cache for all actions. The cache will be rebuilt with the next execution of an action.

Translations panel

Translations backend

In order to use translations backend you need to install SonataAdminBundle and SonataDoctrineORMAdminBundle. Please refer to their installation guide. After installation and configuration the backend will be available under /admin/ao/translation/message/list.

Additional features

Using separate database connection for storing translations

In case you need to share the translations database (eg. when multiple developers collaborate) you can configure separate entity manager for the bundle.

# app/config/config.yml
doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                ...
            # configure translations database connection
            translations:
                ...
                
orm:
    ...
    default_entity_manager: default
    entity_managers:
        default:
            connection: default
            mappings:
                ...
        translations:
            connection: translations
            mappings:
                AOTranslationBundle: ~

ao_translation:
    entity_manager: translations

stof_doctrine_extensions:
    orm:
        ...
        # enable timestampable behavior for translations entity manager
        translations:
            timestampable: true

To create translations schema add use --em parameter like:

app/console doctrine:schema:create --em=translations

ao/translation-bundle 适用场景与选型建议

ao/translation-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.83k 次下载、GitHub Stars 达 24, 最近一次更新时间为 2013 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「i18n」 「ui」 「translation」 「doctrine」 「multilanguage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 ao/translation-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ao/translation-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 ao/translation-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3.83k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 24
  • 点击次数: 26
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 24
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-02-26