matthiasnoback/microsoft-translator-service-provider 问题修复 & 功能扩展

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

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

matthiasnoback/microsoft-translator-service-provider

最新稳定版本:v0.2.0

Composer 安装命令:

composer require matthiasnoback/microsoft-translator-service-provider

包简介

Silex service provider for using the Microsoft Translator V2 API

README 文档

README

By Matthias Noback

Installation

Using Composer, add to composer.json:

{
    "require": {
        "matthiasnoback/microsoft-translator-service-provider": "dev-master"
    }
}

Then using the Composer binary:

php composer.phar install

Register the service provider:

<?php

use MatthiasNoback\Silex\Provider\MicrosoftTranslatorServiceProvider;

$app->register(new MicrosoftTranslatorServiceProvider(), array(
    'microsoft_oauth.client_id' => 'YOUR-CLIENT-ID',
    'microsoft_oauth.client_secret' => 'YOUR-CLIENT-SECRET',
);

Usage

This service provider wraps the corresponding Microsoft Translator V2 API PHP library and adds the translator as the service microsoft_translator to your application.

You need to register your application at the Azure DataMarket and thereby retrieve a "client id" and a "client secret". Copy these values to the right keys in the options array (see above):

Making calls

Translate a string

// in your controller

$translatedString = $app['microsoft_translator']->translate('This is a test', 'nl', 'en');

// $translatedString will be 'Dit is een test', which is Dutch for...

Detect the language of a string

$text = 'This is a test';

$detectedLanguage = $app['microsoft_translator']->detect($text);

// $detectedLanguage will be 'en'

Get a spoken version of a string

$text = 'My name is Matthias';

$spoken = $app['microsoft_translator']->speak($text, 'en', 'audio/mp3', 'MaxQuality');

// $spoken will be the raw MP3 data, which you can save for instance as a file

For more examples, see the README of the PHP library

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固