worldia/textmaster-bundle
Composer 安装命令:
composer require worldia/textmaster-bundle
包简介
A Symfony2 bundle integrating textmaster-api
README 文档
README
A Symfony2 bundle integrating textmaster-api.
Installation
Step 1: Download TextmasterBundle using composer
Require the bundle with composer:
$ composer require worldia/textmaster-bundle
Step 2: Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Worldia\Bundle\TextmasterBundle\WorldiaTextmasterBundle(), // ... ); }
Step 3: Configure the bundle
// in app/config/config.yml worldia_textmaster: credentials: api_key: your_api_key api_secret: your_api_secret
Step 4: Add route
The translation manager is using the callback routes.
// in app/config/routing.yml worldia_textmaster_callback: resource: @WorldiaTextmasterBundle/Resources/config/routing/callback.yml
Additional installation
Configuration
By default, the translator provider used is the ArrayBasedMappingProvider. You can easily configure it as followed:
// in app/config/config.yml worldia_textmaster: mapping_properties: AppBundle\Entity\FirstEntity: ['property1', 'property2', 'property3', ...] AppBundle\Entity\SecondEntity: ['propertyA', 'propertyB', 'propertyC', ...] ...
There is a template provided for each route. You can override it easily with configuration:
// in app/config/config.yml worldia_textmaster: templates: project: show: 'MyTemplate:Project:show.html.twig' list: 'MyTemplate:Project:list.html.twig'
Route
You can optionally add object routing files.
If you do you will need white-october/pagerfanta-bundle to display pager on list page.
// in app/config/routing.yml worldia_textmaster_project: resource: @WorldiaTextmasterBundle/Resources/config/routing/project.yml worldia_textmaster_document: resource: @WorldiaTextmasterBundle/Resources/config/routing/document.yml worldia_textmaster_job: resource: @WorldiaTextmasterBundle/Resources/config/routing/job.yml
Usage example
Create a project with documents:
<?php // src/AppBundle/MyService/MyService.php namespace AppBundle\MyService; use Worldia\Bundle\TextmasterBundle\Translation\TranslationManager; class MyService { /** * @var TranslationManager */ protected $translationManager; public function createProject() { // retrieve all entities to translate in array $translatable. $project = $this->translationManager->create( $translatable, 'Project name', 'en', 'fr', 'CO21', 'My poject briefing', array('language_level' => 'premium') ); // the project is sent to TextMaster and launched. } }
API callback
The bundle provide a controller with a route to catch API callback.
This will call textmaster-api Handler to raise en event corresponding to the right object depending on its status.
Then a listener (DocumentListener or ProjectListener) will catch this event and act accordingly.
For example, an event for 'textmaster.document.in_review' will get the job related to the document and finish it.
统计信息
- 总下载量: 15.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2016-05-04