Results 1 to 14 of 14
  1. #1
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default Language translation

    Hi,
    I want to translate text file from one language(eg, english) to other languages in java. how to do this. help me please. thanks.

  2. #2
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    Probably google has a translation api

    google-api-translate-java - Project Hosting on Google Code
    Swastik

  3. #3
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    ya thanks i saw that but i couldnt understand that. can u explain me wat it has given. i have to download any rar files? also that code given is to change language in web pages i think. i need it to be done foe text document. how to do that.thanks again

  4. #4
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    It can be done in desktop applications too, but you need web connectivity to invoke the web service apis. Apart from that you need to download the following two jar files

    Downloads - google-api-translate-java - Project Hosting on Google Code

    http://mirrors.ibiblio.org/pub/mirro...n-20090211.jar

    After downloading the jar files, add them to the classpath, and you can try the sample program they have given, it worked for me.

    In the setHttpReferrer part use this

    Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java");
    Swastik

  5. #5
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    if i download the jar file and run, it gives the error, fails to load main class manifest attribute. wat is that. can u help

  6. #6
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    I am not sure, whether its an executable jar or not. But did you try the steps I suggested?
    Swastik

  7. #7
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    ya i did so. i downloaded it and included in my class path and compiled. i faced the following error: failed to load main class manifest attribute.

  8. #8
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    Did you download both the jar files and set to classpath? Which program are you trying to run.

    try the following code after setting the classpath

    Java Code:
    import com.google.api.translate.Language;
    import com.google.api.translate.Translate;
    
    public class Main {
      public static void main(String[] args) throws Exception {
        // Set the HTTP referrer to your website address.
        Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java");
    
        String translatedText = Translate.execute("Bonjour monde le",
                Language.FRENCH, Language.ENGLISH);
    
        System.out.println(translatedText);
      }
    }
    Swastik

  9. #9
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    ya i did. it shows error as package doesnot exist. and error in the line

    translatedText = Translate.execute("Bonjour monde le", Language.FRENCH, Language.ENGLISH);

  10. #10
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    Either you haven't downloaded both jar files or the classpath is not properly set. The code did work for me.
    Swastik

  11. #11
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    i downloaded both the jar files. And i executed that code in netbeans only. should i include both the jar files in netbeans?

  12. #12
    dswastik is offline Senior Member
    Join Date
    Dec 2008
    Location
    Kolkata
    Posts
    282
    Rep Power
    6

    Default

    Yes, you have to include the jar files under application classpath in netbeans.
    Swastik

  13. #13
    archanaanbu is offline Member
    Join Date
    Feb 2011
    Posts
    21
    Rep Power
    0

    Default

    hey i got it. thanks lot for replying me patiently. really i feel very happy to clarify my doubts in java forum. thanks again.

  14. #14
    Awais261 is offline Member
    Join Date
    Feb 2011
    Posts
    3
    Rep Power
    0

    Default

    I want to translate text file from one language(eg, english) to other languages in java.

Similar Threads

  1. Rotation & translation combined
    By ScottVal in forum Java 2D
    Replies: 4
    Last Post: 02-27-2011, 06:57 PM
  2. Idea for Meaning Translation
    By OmerHalit in forum AWT / Swing
    Replies: 5
    Last Post: 07-08-2010, 07:19 PM
  3. WORD Translation HELP PLZ :(
    By sammypants in forum New To Java
    Replies: 2
    Last Post: 11-24-2009, 01:46 PM
  4. X / Y Translation Problem
    By SkinnyK in forum New To Java
    Replies: 4
    Last Post: 01-16-2009, 12:20 AM
  5. Transform Rotation Translation
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-21-2008, 08:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •