rakesh441 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

could not convert from hindi to english #55

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. I copied given code
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 compiled it.
2. When i run this code it show me ????? on console as well as when i used 
this code in my jsp
3. any clues??

Original issue reported on code.google.com by patil.go...@gmail.com on 22 Jun 2009 at 12:31

GoogleCodeExporter commented 8 years ago
Issue 56 has been merged into this issue.

Original comment by rich.mid...@gmail.com on 22 Jun 2009 at 6:10

GoogleCodeExporter commented 8 years ago
Your example code shows translating from French to English, which should be 
flawless.

That you say it's converting Hindi to English suggests that maybe it's a 
character 
encoding issue. Perhaps try it on Linux instead of Windows.

It think it highly unlikely though that this is an issue with the translate 
library.

Original comment by rich.mid...@gmail.com on 22 Jun 2009 at 6:11

GoogleCodeExporter commented 8 years ago
Actually i copy and paste that example from sample as it is, thats why french 
is there.
I am trying this on widows only. it coverts  from hindi to english after i 
changed 
encoding as UTF-8 but it is unable to covert that in english to hindi. I am 
using 
Eclipse 3.3 for its testing. I tried this in my web application but didn't help 
:(

Regards,
Gopal

Original comment by patil.go...@gmail.com on 23 Jun 2009 at 4:20

GoogleCodeExporter commented 8 years ago
Dear gopal, you put in header of jsp file as below: 
 <%@ page contentType="text/html;charset=UTF-8" %>

or in Servlet

response.setContentType("text/html;charset=UTF-8"); 

then u will get as your expected output

Thanks

Original comment by ashish...@gmail.com on 24 Nov 2009 at 11:45

GoogleCodeExporter commented 8 years ago
Did you solve the problem? I have the same problem with the following code: 

//this does not work, but i guess i have to do something like this..
System.setProperty("http.contentType","text/html;charset=UTF-8");

        Translate.setHttpReferrer("http://translate.google.pl");
        try {
            String trans = Translate.execute("Dog eat dog", 
Language.ENGLISH, Language.CHINESE_SIMPLIFIED);
            System.out.println(trans);

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

I am using the java API in an JFace application.

Original comment by brismad...@gmail.com on 23 Apr 2010 at 11:08