-
-
Save dsauerbrun/cdd8ae68fe50900b37e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bingTranslate(message,originLang,destLang,accessToken){ | |
Promise.try(function(){ | |
accessToken.then(function(bingToken){ | |
options = { | |
headers:{ | |
'Authorization': "Bearer "+bingToken | |
} | |
}; | |
queryString="text="+encodeURIComponent(message)+"&from="+originLang+"&to="+destLang+"&contentType=text%2Fplain"; | |
return bhttp.get("http://api.microsofttranslator.com/V2/Http.svc/Translate?"+queryString,options) | |
}).then(function(data){ | |
return xml.parseBuffer(data.body).childs[0]; | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment