Provides a simple, unofficial, Java client API for using Google Translate.
News
Existing users please note - we've enforced setting the HTTP referrer as of version 0.7, which was previously optional. I believe this value should be set to your website address ideally, to help Google monitor who's using the APIs and allow them to contact you if necessary.
I've updated the wiki example GUI application.
Proxy configuration details have also been added to the wiki.
Install
Simply include the google-api-translate-java.jar file in your application's classpath.
Quickstart
This is our "Hello World" example:
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
public class Main {
public static void main(String[] args) throws Exception {
// Set the HTTP referrer to your website address.
Translate.setHttpReferrer(/* Enter the URL of your site here */);
String translatedText = Translate.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH);
System.out.println(translatedText);
}
}Well done. You're now an expert in using this API! The wiki has a more complete example usage within a desktop application.
Features
Small library size - less than 50Kb.
Uses English as an intermediate language to attempt translations between language pairings that are unsupported directly by Google Translate.
The jar is runnable and has a very lightweight GUI to demonstrate translation functionality.
Now available via a Maven plugin.
Problems / Suggestions?
Please do report an issue if you find any bugs or have any feature requests.