Giter Site home page Giter Site logo

ms-translator's Introduction

ms-translator

Build Status Scrutinizer Code Quality

Translate text using the Bing Translate API

##Instruction

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

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!

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

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

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:

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.

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

then the code

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

ms-translator's People

Contributors

gidkom avatar

Stargazers

Mohammad Prince avatar Tudorache Leonard Valentin avatar Zoltan Peto avatar  avatar

Watchers

 avatar

Forkers

sankam-nikolya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.