GithubHelp home page GithubHelp logo

seankarson / mstranslator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nanek/mstranslator

0.0 0.0 0.0 63 KB

Microsoft Translator API module for node.js

License: MIT License

JavaScript 100.00%

mstranslator's Introduction

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

Or if you've already migrated to portal.azure.com: Your api key is needed to create a token. Details at https://translatorbusiness.uservoice.com/knowledgebase/articles/1078534-microsoft-translator-on-azure

Example Usage - Auto-generated token

var MsTranslator = require('mstranslator');
// Second parameter to constructor (true) indicates that
// the token should be auto-generated.

// old token API
var client = new MsTranslator({
  client_id: "your client_id" // use this for the old token API
  , client_secret: "your client secret" // use this for the old token API
}, true);

// new token API
var client = new MsTranslator({
  api_key: "your portal.azure.com api key" // use this for the new token API. 
}, 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 client = new MsTranslator({
  api_key: "your portal.azure.com api key" // use this for the new token API. 
}, true);

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.

mstranslator's People

Contributors

nanek avatar paazmaya avatar sorinsarca avatar mikelohmann avatar arieljake avatar meritt avatar jimkang avatar illusionmh avatar sandinmyjoints avatar brooklyndev avatar

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.