We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › google translate
Page Index Toggle Pages: 1
google translate (Read 1780 times)
google translate
Jul 29th, 2009, 10:41am
 
Does Processing support the Google Translate API in Java? I didn't get it to work, but was wondering whether I missed something, cause I am quite new to programming.

Thanks
Re: google translate
Reply #1 - Jul 29th, 2009, 11:54am
 
Processing should support all Java libraries.
Perhaps show what you tried.
Re: google translate
Reply #2 - Jul 30th, 2009, 9:42am
 
I just copied it from the code.google.com website, imported the oogle-api-translate-java.jar file and tried to run it. It says "Cannot parse error text: File /tmp/build55883.tmp/Main.java is missing. The code is below.
Thanks



import com.google.api.translate.Language;
import com.google.api.translate.Translate;

public class Main {
 public static void main(String[] args) {
   try {
     String translatedText = Translate.translate("Bonjour le monde", Language.FRENCH, Language.ENGLISH);
     System.out.println(translatedText);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
}


Re: google translate
Reply #3 - Jul 30th, 2009, 12:41pm
 
You have to adapt to Processing syntax/way of doing stuff.
For example:
Code:
import com.google.api.translate.Language;
import com.google.api.translate.Translate;

try {
String translatedText = Translate.translate("Bonjour le monde", Language.FRENCH, Language.ENGLISH);
println(translatedText);
} catch (Exception ex) {
ex.printStackTrace();
}

is enough.
Re: google translate
Reply #4 - Aug 1st, 2009, 9:14am
 
thanks a lot.
Re: google translate
Reply #5 - Aug 1st, 2009, 10:36am
 
@adnil, does it work? would you provide a little working example and tell us what you had to install(libraries etc). i believe this is interesting for other people too... Thank you!
Re: google translate
Reply #6 - Aug 14th, 2009, 2:01am
 
yes it does. You just have to download the library from here http://code.google.com/p/google-api-translate-java/ and import to your sketch. Instead of the java code that is given on that website the code by PhiLho works. I haven't really worked on expanding the code and integrating it into my program yet, but I think there are more extensive java examples on the net.
Page Index Toggle Pages: 1