richmidwinter / google-api-translate-java Goto Github PK
View Code? Open in Web Editor NEWJava wrapper for the Google Translate service
Home Page: http://code.google.com/p/google-api-translate-java/
Java wrapper for the Google Translate service
Home Page: http://code.google.com/p/google-api-translate-java/
Hello,
I looking arround have paid access (whith key)
but it doesn't work
no use of my key, check that in the api google console report graph.
so I keep having the quota exceed response. so bad
I've notice that for paid acces, the url is different (secured one):
https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&q=hello%20world&source=en&target=de
instead of
http://ajax.googleapis.com/ajax/services/language/translate
in the source
change it on java doesn't made me go anywhere.
if you thought about something.
thank you anyway, your little wrapper was a good one.
The tests are nice, but they kind of fail, because Google is translating the same stuff differently in 2014 than in 2012.
I am not sure of any long-term solution, other than keep updating the tests continually.
Is the latest version of this on Maven Central?
The API simply returns a blank text now. Maybe Google changed their format?
Is it able to fix it, or is it complicated?
Thanks.
Microsoft Translate API looks like it shouldn't be hard to add. It sometimes returns better results (sometimes not) and it's cheaper.
I will try to fork this project and add it myself.
When v2 version always uses the GET method to the google api service.
The next modifications will restore the use of POST (like in the v1 variant):
GoogleAPI.java, line 117 insert:
uc.setRequestProperty("X-HTTP-Method-Override", "GET");
TranslateV2.jave, line 40-71 replace with
/**
* Constants.
*/
private static final String URL = "https://www.googleapis.com/language/translate/v2";
private static final String PAR_TEMPLATE = "key=%s&q=%s&target=%s";
/**
* {@inheritDoc}
*/
@Override
public String execute(final String text, final Language from, final Language to) throws GoogleAPIException {
try {
validateReferrer();
if (key == null) {
throw new IllegalStateException("You MUST have a Google API Key to use the V2 APIs. See http://code.google.com/apis/language/translate/v2/getting_started.html");
}
final String parameters = String.format(PAR_TEMPLATE, key, URLEncoder.encode(text, ENCODING), to.toString())
+ (Language.AUTO_DETECT.equals(from) ? "" : String.format("&source=%s", from.toString()));
final URL url = new URL(URL);
final JSONObject json = retrieveJSON(url,parameters);
return getJSONResponse(json);
} catch (final Exception e) {
System.out.println("Error: " +e.getMessage());
throw new GoogleAPIException(e);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.