Skip to content

Instantly share code, notes, and snippets.

@spf2
Created October 13, 2016 22:05
Show Gist options
  • Save spf2/3e5718aa07a14f1f28859666a819f0a5 to your computer and use it in GitHub Desktop.
Save spf2/3e5718aa07a14f1f28859666a819f0a5 to your computer and use it in GitHub Desktop.
var yandexUrl = "https://translate.yandex.net/api/v1.5/tr.json/translate";
var yandexKey = "trnsl.1.1.20160825T224654Z.60d8da3a9f67c52b.ba2dfcc5fcd88c42ed64e266a52c105911fce47c";
function getMessageActions(bubble) {
return [[
"Translate",
function(bubble, peers) {
var url = yandexUrl + "?key=" + yandexKey + "&lang=en-es&text=" + encodeURI(bubble.body);
util.fetch(url).then(function(response) {
var json = JSON.parse(response.body);
bubble.body = json.text[0];
});
}
]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment