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 & HelpOther Libraries › Translation of Strings
Page Index Toggle Pages: 1
Translation of Strings (Read 694 times)
Translation of Strings
Feb 20th, 2009, 7:58am
 
I'm very new to Java, but I am trying to get some form of language translation in a project I'm working on.  I found this google translation library
http://code.google.com/p/google-api-translate-java/
I downloaded the .jar file and renamed it googletranslate and put it in libraries>googletranslate>library

To try to get things going, I tried to run the basic Hello World example:

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("Salut le monde", Language.FRENCH, Language.ENGLISH);
     System.out.println(translatedText);
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
}

And I get the error:
File C:\Users\RYANJO~1\AppData\Local\Temp\build26475.tmp\Main.java is missing

I don't really know what Main.java is referring to.  If anyone can help, I would really appreciate it!  

I think this could be a very cool resource, it has capabilities of recognizing which language a string is in and translating it to one or several other languages...


Re: Translation of Strings
Reply #1 - Feb 20th, 2009, 12:06pm
 
You show Java code, not Processing code...

I guess you have named your sketch "Main". There might be a clash of names.
Beside, if you have put this code in a .pde file, it will be an internal class, so the main() method is not accessible, I think.

In other words, try using Processing code to test the library.
Re: Translation of Strings
Reply #2 - Feb 20th, 2009, 12:35pm
 
In other words:

Code:

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

void setup(){
try {
String translatedText = Translate.translate("Salut le monde", Language.FRENCH, Language.ENGLISH);
println(translatedText);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Re: Translation of Strings
Reply #3 - Feb 20th, 2009, 10:44pm
 
Wow, awesome!  Thanks for that.  I didn't really have any idea where to start with turning the Java code example into Processing code.  I have had some luck before running bits of Java code without change...it is cool to see how simple the change was.  Thanks!
Page Index Toggle Pages: 1