LokenathHBK / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

support google translate v2 #152

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
First thank you for this wonderful, reliable code that I have been suing for 
quite some time.

Would it be possible to support the v2 of the Translate API, in the wake of the 
announced closing of v1 on the 1st december 2011?

Original issue reported on code.google.com by mils...@gmail.com on 17 Oct 2011 at 1:15

GoogleCodeExporter commented 8 years ago
The attached file provide support for V2 of the Google translate APIs.
And the attached jar file is a 0.96-SNAPSHOT with that file added.

Original comment by william....@gmail.com on 27 Oct 2011 at 10:27

Attachments:

GoogleCodeExporter commented 8 years ago
Does this require another jar, Im now getting:

Exception in thread "Thread-6" java.lang.NoClassDefFoundError: 
org/json/JSONObject
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:127)
    at com.google.api.translate.Translate.execute(Translate.java:69)
    at prman.model.trans.GoogleTranslator$GoogleTranslationEngine.search(GoogleTranslator.java:115)
    at prman.model.trans.AbstractTranslation.run(AbstractTranslation.java:54)

Original comment by paultay...@jthink.net on 31 Oct 2011 at 4:56

GoogleCodeExporter commented 8 years ago
As Rich outlined at http://code.google.com/p/google-api-translate-java/ the 
JSON implementation has been split out of the project. So you will need to 
include that.

Original comment by william....@gmail.com on 31 Oct 2011 at 8:43

GoogleCodeExporter commented 8 years ago
Thx, didnt notice that I think its also worth pointing out you need to change 
your code to use TranslateV2 rather than Translate it wont just start working 
magically.
Now working.

Original comment by paultay...@jthink.net on 1 Nov 2011 at 12:29

GoogleCodeExporter commented 8 years ago
can someone tell me what are the differences in implementation in the code 
between v1 and v2 Apis?
especially for use in jsp, following the example of the following url, which I 
have the api v1. I read that only need to add before running, the NEXT line, 
-GoogleAPI.setKey ("api_key");

http://code.google.com/p/google-api-translate-java/

I can help change or add what is needed to use the api v2

Original comment by luis....@gmail.com on 4 Nov 2011 at 5:17

GoogleCodeExporter commented 8 years ago
You need to
1) Use TranslateV2 instead of Translate
2) You need to set an API key.

The only thing that is needed is for someone to commit my patch above.

Original comment by william....@gmail.com on 5 Nov 2011 at 3:13

GoogleCodeExporter commented 8 years ago
Thanks for the patch William. Should be in version 0.97 if I haven't made any 
omissions.

An instance of TranslateV2 is available from Translate.DEFAULT now.

Original comment by rich.mid...@gmail.com on 5 Nov 2011 at 5:13