textToTranslate = "Syed Ali Nayyar Nasir";
targetLang = "ar";
// Arabic
apiKey = "AIzaSyCtqtqWGfnZ1EAYXD9pGhQoZ6QtkflC270";
// replace with your actual key
url = "https://translation.googleapis.com/language/translate/v2?key=" + apiKey;
params = Map();
params.put("q",textToTranslate);
params.put("target",targetLang);
params.put("source","en");
// optional
headers = Map();
headers.put("Content-Type","application/x-www-form-urlencoded");
response = invokeurl
[
url :url
type :POST
parameters:params
headers:headers
];
info response;
translation = response.get("data").get("translations").get(0).get("translatedText");
info translation;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter