0

It took me about 5 minutes to use the Google Translate REST API from Javascript, NodeJS, WGET and Java via Sun's Jersey library, but I cannot find any working examples for the current version of the official Google Java Client (rev41), or how to configure it using Maven. I sat for an entire morning trying to work it out from the source code (and swearing a lot) to no avail. Working out the Maven stuff was easy enough but I cannot for the life of me work out how to use the Java API - a crazy situation as it took so little time using basic generic technology.

For reference - this is my Maven config:

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-translate</artifactId>
    <version>v2-rev41-1.20.0</version>
</dependency>

My bigger question to the lovely Google folk is - why is the Java library harder to implement than using straight REST? Surely the sole purpose of the Java library is to provide a wrapper that makes using Google Translate simpler, and there are only about 3 REST calls to wrap, how hard can it be? What exists now would appear to be the opposite: a number of web articles actually recommend using a thirdParty non-official Java library, or even Google's text-to-speech service (How to use Google Translate API in my Java application?). All of this suggests to me that this area needs some attention or should be thrown in the bin, it's not currently adding any value.

Community
  • 1
  • 1
Oly Dungey
  • 1,603
  • 19
  • 20

1 Answers1

0

The second part of the question is not answerable, as it isn't specific and instead seems like a loaded question. I'll just answer the first part.

The Maven config can be found in the Translate documentation for the Java API Client. In the "Add Library to Your Project" section, click "Maven."

Although there is not an example specific to Translate, you can take a look at other samples, such as the CalendarSample. If there is a specific step that still isn't obvious please bring it up specifically, such as OAuth, constructing the Translate class, or knowing where to start. I'll also note that the Translate JavaDocs are linked to from the above documentation.

Eric Anderson
  • 24,057
  • 5
  • 55
  • 76
  • The Maven and OAuth documentation is great. I have looked through the JavaDoc a number of times and had a go at using it but it doesn't give enough clues on how it is intended to be used.I could spend further time trying to work it out but that is what my loaded question is about - without some simple examples its much easier to just use REST calls instead. – Oly Dungey Jun 05 '15 at 15:46
  • 1
    You want to create an instance of `com.google.api.services.translate.Translate`. It would be very similar to the calendar sample creating Calendar. Then you would issue a call with something like `translate.languages().list().execute()` – Eric Anderson Jun 08 '15 at 13:44