docteurklein/translator-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

docteurklein/translator-bundle

Composer 安装命令:

composer require docteurklein/translator-bundle

包简介

This bundle's purpose is to provide an interface for edition, addition and deletion of translations messages.

关键字:

README 文档

README

This bundle's purpose is to provide an interface for edition, addition and deletion of translations messages.

Currently supported formats:

  • YAML
  • XLIFF
  • CSV

Install & setup the bundle

  1. Install via composer
    composer require docteurklein/translator-bundle=~3.0
  1. Add the bundle to your AppKernel class
    // app/AppKernerl.php
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Knp\Bundle\TranslatorBundle\KnpTranslatorBundle,
            // ...
        );
        // ...
    }
  1. Add routing
    // app/config/routing.yml

    knplabs_translator_admin:
        resource: @KnpTranslatorBundle/Resources/config/routing/edition.yml
            prefix:   /trans/admin

    knplabs_translator:
        resource: @KnpTranslatorBundle/Resources/config/routing/routing.yml
            prefix:   /trans

These route files provide the following routes:

[router] Current routes
Name                     Method  Pattern
knplabs_translator_list  GET    /trans/admin/list
knplabs_translator_get   GET    /trans/{id}/{domain}/{locale}
knplabs_translator_put   PUT    /trans/

Minimal configuration

This bundle requires the activation of the core translator:

    // app/config/config.yml
    framework:
        # ...
        translator:    { fallback: en }
        # ...

Additional configuration

This bundle relies on the Ext Core library. You can decide wheter or not it will be included automatically.

    knplabs_translator:
        include_vendor_assets: false # defaults to true

Services

This bundle introduces those services:

knp_translator.dumper.csv                    container Knp\Bundle\TranslatorBundle\Dumper\CsvDumper
knp_translator.dumper.xliff                  container Knp\Bundle\TranslatorBundle\Dumper\XliffDumper
knp_translator.dumper.yaml                   container Knp\Bundle\TranslatorBundle\Dumper\YamlDumper
knp_translator.writer                        container Knp\Bundle\TranslatorBundle\Translation\Writer

controllers are services too:

knp_translator.controller.edition    request   Knp\Bundle\TranslatorBundle\Controller\EditionController
knp_translator.controller.translator request   Knp\Bundle\TranslatorBundle\Controller\TranslatorController

API

Updating a given translation key is really simple:

    $this->get('translator.writer')->write('the key to translate', 'the translated string', 'messages', 'en');

Rest API

  • Update english translations files for domain tests with translated value for key foo.bar.baz
    curl -X PUT http://project-url/trans/  \
        -F 'id=foo.bar.baz' \
        -F 'domain=messages' \
        -F 'locale=en' \
        -F 'value=translate value' 
  • Get the translated value of key foo.bar.baz for english locale for tests domain
    curl http://project-url/trans/foo.bar.baz/tests/en

统计信息

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

GitHub 信息

  • Stars: 46
  • Watchers: 3
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-07-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固