2017 © Pedro Peláez
 

library ms-translator

Translate text using the Microsoft Translate API

image

gidkom/ms-translator

Translate text using the Microsoft Translate API

  • Friday, February 27, 2015
  • by gidkom
  • Repository
  • 1 Watchers
  • 1 Stars
  • 406 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

ms-translator

Build Status Scrutinizer Code Quality, (*1)

Translate text using the Bing Translate API, (*2)

Instruction

Translate your texts using Microsoft's Bing Translation services HTTP API http://msdn.microsoft.com/en-us/library/ff512419.aspx, (*3)

The code is based on the one provided by Microsoft at the documentation, prepared for composer. In two lines, you can have a translation service working!, (*4)

Before working with the code, get your Access Token, using your MSN account. More info: http://msdn.microsoft.com/en-us/library/hh454950.aspx, (*5)

Don't get confused with the clientID. It's not the Customer ID nor your account key. The clientID is the text (possibly your app name or some plain-language text) that you specified when registering your application. You can view your client id https://datamarket.azure.com/developer/applications, (*6)

There is a free data tier of 2 million characters per month. Check https://datamarket.azure.com/account/datasets if you haven't used yet your monthly limit:, (*7)

Installation

### With Composer

The easiest way to install is via composer. Create the following composer.json file and run the php composer.phar install command to install it., (*8)

{
    ...
    "require": {
        "gidkom/ms-translator": "dev-master"
    }
}

then the code, (*9)


include "vendor/autoload.php"; $client_id = 'abc'; $client_secret = 'xyz'; $mt = new Gidkom\MsTranslator\MsTranslator($client_id, $client_secret); //Translate to single language $from = 'en'; $to = 'fr'; return $mt->translate('Hello world', $to, $from); // To auto detect language leave out the $from argument return $mt->translate('Hello world', $to); Translate to multiple languagues $from = 'en'; $to= ['fr', 'de']; return $mt->multiTranslate('Hello world', $to, $from);

for a list of all supported languages and codes go to public/ms-translator-language-codes.txt, (*10)

The Versions

27/02 2015

dev-master

9999999-dev https://github.com/gidkom/ms-translator

Translate text using the Microsoft Translate API

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.0

 

by Gideon Kombian

language translate microsoft