问题
I'm working on a transliteration project in Java Swing. It can access the internet, but I'm unable to set it up. How do we do that? Do we need to download the Google API libraries or just a function call will do?
Here are some useful Transliteration links:
The Google Transliterate API Devloper's Guide
Google API library for Java for download
(I think it has all API libraries of Google:Translate, transliterate, search, etc.)
I spent a lot of time, but Icouldn't find how to set up the Transliteration API, not even at SO.
回答1:
Seems the transliteration API is deprecated and is not included in the Java client, only in the JavaScript client.
The actual calls the JS library makes are pretty simple and could easily be replicated from anywhere:
http://www.google.com/inputtools/request?ime=transliteration_en_ru&num=5&cp=0&cs=0&ie=utf-8&oe=utf-8&text=prosto
Don't know if doing that is against Google's terms, though. Probably it is.
You could also try running the Ajax client in Rhino. You'll need env-js which provides a pure javascript DOM environment.
It's just hideous enough to work!
来源:https://stackoverflow.com/questions/9134899/google-transliteration-api-in-java-swing-project