Closed saroyama closed 8 years ago
@dean1510 What are your thoughts on this issue? @saroyama Let me know if you can find where exactly the codes are differing (via a debugger or something) it likely has to due with a difference of order of operations between PHP and Java.
Unfortunately, I did not work too much on the token generation, but if you can find exactly at what line the code begins to differ, that would prove most helpful.
Problem isn't related to TK calculation algorithm. You should run it on original string: String encoded = URLEncoder.encode(text, "UTF-8"); //Encode At this time "green apple" is converted to "green+apple" ... sb.append(generateToken(encoded)); TK is calculated on converted string, not original source => You get an error.
Try use sb.append(generateToken(text)); instead.
Thanks for the info. I submitted a bugfix and uploaded the latest binaries.
@dean1510 I'm doing it exactly as you wrote, and i using original GoogleTranslate class without any changes from my side. But first url ok: http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=825315.704312 Second, not: http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green+apple&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=514818.127961
@saroyama New binaries seem to be working for me. Green Apple is returning manzana verde. Maybe we need to update generateB to use the West Coast locale? I am using it right now and it appears to be working.
@saroyama ensure you're calling TK exactly on "green apple". I've changed "+" in your URL to "%20" but it also returns error.
@dean1510 System.out.println(generateURL("en", "es", "green apple")); return this url: http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green+apple&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=514818.127961 and it return 403 error
@dean1510 Sorry, i get new class, now all works
Thanks for you job. I try to use GoogleTranslate class, when i use one keyword all works excelent, but if i try to translate two or more words, token is wrong and google return 403 error. Although @helen5106 php version generate correct token with multiply words, for example: green=764880.885612 green apple=367137.242333 // correct and java generated tokens: green=764880.885612 green apple=80012.462896 // wrong