-
-
Save anonymous/dc8ee85d6b763c30ac58 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
// import libraries | |
jetpack.future.import("menu"); | |
jetpack.future.import("selection"); | |
// create a new menu item | |
jetpack.menu.context.page.add({ | |
label: "TranslateIt!", | |
command: function() { TranslateIt(); } | |
}); | |
// do translate | |
function TranslateIt() { | |
var url = 'http://ajax.googleapis.com/ajax/services/language/translate?v=1.0' | |
+ '&langpair=|zh-TW' | |
+ '&q=' + escape(jetpack.selection.text); | |
$.getJSON(url, function(result) { | |
if (result.responseStatus == 200) { | |
jetpack.notifications.show(result.responseData.translatedText); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment