goxr3plus / java-google-translator

Full Google Translate Support using Java
GNU General Public License v3.0
12 stars 8 forks source link

does it still work? #1

Open newthings4learning opened 4 years ago

newthings4learning commented 4 years ago

I tried using it but it gives below exception -

java.net.UnknownHostException: translate.google.com at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:463) at sun.net.www.http.HttpClient.openServer(HttpClient.java:558) at sun.net.www.http.HttpClient.<init>(HttpClient.java:242) at sun.net.www.http.HttpClient.New(HttpClient.java:339) at sun.net.www.http.HttpClient.New(HttpClient.java:357) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) at com.darkprograms.speech.translator.GoogleTranslate.urlToText(GoogleTranslate.java:173) at com.darkprograms.speech.translator.GoogleTranslate.translate(GoogleTranslate.java:149) at com.darkprograms.speech.translator.GoogleTranslate.translate(GoogleTranslate.java:130) at translator.TranslatorExample.main(TranslatorExample.java:20)

goxr3plus commented 4 years ago

This project is based on my other project https://github.com/goxr3plus/java-google-speech-api

Which i haven't updated a long time , please check https://github.com/goxr3plus/java-google-speech-api/issues/11 if you want you can fix it :)

goxr3plus commented 4 years ago

@newthings4learning

newthings4learning commented 4 years ago

This project is based on my other project https://github.com/goxr3plus/java-google-speech-api

Which i haven't updated a long time , please check goxr3plus/java-google-speech-api#11 if you want you can fix it :)

well ... i took the GoogleTranslate class and update the URL to "https://translate.google.com/#view=home".

also inside generateURL i updated and added the new parameter as sb.append("&op=translate"). also changed sb.append("&q="); to sb.append("&text=");

however i believe the response that comes back from Google has changed quite a lot. As this line probably is not working as intended ans only returns "en" always - String[] raw = rawData.split("\"");//Parses the JSON