I want to translate word with ajax request to google translate If i use curl, it willl be like:
curl_init("http://translate.google.com/translate_a/t?client=t&text=hello&sl=en&tl=ru");
But i cant use server-side scripts with queries because they will be from same IP
But i cant use JSONP request too, because it's not allowed i think. Here's server response:
[[["привет","hello","privet",""]],[["",["Алло","Здравствуйте."]],["имя существительное",["приветствие","приветственный возглас","возглас удивления"]],["глагол",["здороваться","звать","окликать"]],["междометие",["привет","здравствуйте","алло"]]],"en",,[["привет",[5],1,0,1000,0,1,0]],[["hello",4,,,""],["hello",5,[["привет",1000,1,0],["Здравствуй",0,1,0],["Здравствуйте",0,1,0],["Hello",0,1,0]],[[0,5]],"hello"]],,,[["en"]],13]
And i cant load content to iframe
<iframe src="http://translate.google.com/translate_a/t?client=t&text=hello&sl=en&tl=ru"></iframe>
because response content type is "text/javascript" and browser downloads a file
PS. i cant decode content with php function json_decode() or with jquery.ajax because response json is corrupt. You can test it here http://json.parser.online.fr/
Give me an advice, please
The translate-json.js node script is simple. It takes an api key, input .json file, and a comma separated list of language codes supported by Google Translate. Full list here. Here’s an example from the repo:
The translate-json.js node script is simple. It takes an api key, input.json file, and a comma separated list of language codes supported by Google Translate.
It takes an api key, input .json file, and a comma separated list of language codes supported by Google Translate. Full list here. Here’s an example from the repo:
The translations array contains two translatedText fields with translations provided in the requested target language ( de: German). The translations are listed in the same order as the corresponding source array in the request. Before trying this sample, follow the Go setup instructions in the Translation quickstart using client libraries .
Try:
http://translate.google.com/translate_a/t?client=p
if the client parameter is anything other than 't' it returns valid JSON data. Of course, you could always transform the 't' return variable into a valid array or JSON but this is easier.
Make sure to add header param "User-Agent" = "Mozilla/4.0". Google adds captcha if you do not
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With