Skip to content
Microsoft Translator API module for node.js
JavaScript
Latest commit 2fafa68 May 12, 2016 @nanek 2.0.8

README.md

Microsoft Translator API module for node.js

Microsoft Translator Documentation

devDependency Status

SOAP version that supports translating longer strings

Methods

Microsoft Translator API Reference

API Docs

  • addTranslation
  • addTranslationArray (not implemented)
  • breakSentences (not working)
  • detect
  • detectArray
  • getLanguageNames
  • getLanguagesForSpeak
  • getLanguagesForTranslate
  • getTranslations
  • getTranslationsArray
  • speak
  • translate
  • translateArray
  • translateArray2

Installation

$ npm install mstranslator

You will also need to register to get an client_id and client_secret to create access tokens. Details at http://msdn.microsoft.com/en-us/library/hh454950.aspx

Example Usage - Auto-generated token

var MsTranslator = require('mstranslator');
// Second parameter to constructor (true) indicates that
// the token should be auto-generated.
var client = new MsTranslator({
  client_id: "your client_id"
  , client_secret: "your client secret"
}, true);

var params = {
  text: 'How\'s it going?'
  , from: 'en'
  , to: 'es'
};

// Don't worry about access token, it will be auto-generated if needed.
client.translate(params, function(err, data) {
  console.log(data);
});

Example Usage - Generate token manually

var MsTranslator = require('mstranslator');
var client = new MsTranslator({
  client_id: "your client_id"
  , client_secret: "your client secret"
});

var params = {
  text: 'How\'s it going?'
  , from: 'en'
  , to: 'es'
};

// Using initialize_token manually.
client.initialize_token(function(keys){
  console.log(keys.access_token);
  client.translate(params, function(err, data) {
    console.log(data);
  });
});

Tests

npm test

License

Licensed under the MIT license.

Something went wrong with that request. Please try again.