Created
October 13, 2016 22:05
-
-
Save spf2/3e5718aa07a14f1f28859666a819f0a5 to your computer and use it in GitHub Desktop.
This file contains 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
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