textking/api 问题修复 & 功能扩展

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

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

textking/api

Composer 安装命令:

composer require textking/api

包简介

Library to access the TEXTKING REST API for human translation.

README 文档

README

This library provides an object oriented interface to the TEXTKING translation API. The TEXTKING translation API is a RESTful web service which allows you to automate your translation processes using the high quality human translations offered by the TEXTKING translation agency.

Features

  • Get information about your prepared, running and completed translation projects.
  • Create and commission new translation projects
  • Upload documents for translation in various file formats
  • Perform a cost analysis for uploaded documents
  • Get informed about the state of a translation in progress
  • Download the translated documents

Requirements

Installing via Composer

The recommended way to install the TEXTKING API is through Composer.

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add TEXTKING API as a dependency
php composer.phar require textking/api:~0.1

This will install the TEXTKING API and its dependencies into your project.

After installing, you need to require Composer's autoloader:

require 'vendor/autoload.php';

Usage

The following example demonstrates how you can use the TEXTKING API to submit a text for translation.

<?php
require __DIR__ . '/../vendor/autoload.php';

use TextKing\Model\Project;
use TextKing\Model\Job;
use TextKing\Model\Document;

// This is your OAuth 2 access token
// See https://github.com/TextKing/textking-api/wiki/Authorization-and-authentication
define("API_ACCESS_TOKEN", "youraccesstoken");

// Create a new service instance
$service = new Service(API_ACCESS_TOKEN);

// Create a new translation project
$project = new Project();
$project->setName("My translation project");
$project = $service->createProject($project);

// Now add a new translation job English to German to the project.
// A project can have multiple jobs.
$job = new Job();
$job->setName("My translation job");
$job->setSourceLanguage("en");
$job->setTargetLanguage("de");
$job->setQuality(Job::QUALITY_TRANSLATION);
$job = $this->service->createJob($project->getId(), $job);

// We have to upload the text to translate to the job.
// This could be a file stream, but in this example we just
// use some plain text.
$text = "In another moment down went Alice after it, never once considering how in the world she was to get out again.";
$document = Document::createFromString($text);
$this->service->uploadDocument($project->getId(), $job->getId(), $document);

// Now get an updated version of the project to see the pricing.
$project = $service->getProject($project->getId());
echo "Net price: " . $project->getNetPrice() . " " . $project->getCurrency() . "\n"
echo "VAT: " . $project->getVat() . " " . $project->getCurrency() . "\n"
echo "Expected delivery date: " . $project->getDueDate() . "\n"

// To actually order the translation we have to start the project by
// setting it's state "running".
// PLEASE NOTE: You will be charged for the translation once you do this.
// $project->setState(Project::STATE_RUNNING);
// $project = $this->service->updateProject($project->getId(), $project);

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-12-18