Wednesday, August 8, 2007

Building auto-translator based on google translate API (1)

I am writing an auto-translator plug-in. which will do the i18n for eclipse plugins and application automatically. After evaluate several online translating engine, i think google translate is more accurate. Although google does no provide an official API for their translate yet.

Here is the translation mode definition class. It lists all translation directions supported by google so far.


public final class TranslateMode {
public static final TranslateMode ARABIC2ENGLISH= new TranslateMode("ar|en");
public static final TranslateMode CHINESE2ENGLISH = new TranslateMode("zh|en");
public static final TranslateMode CHINESECN2CHINESETW = new TranslateMode("zh-CN|zh-TW");
public static final TranslateMode CHINESETW2CHINESECN = new TranslateMode("zh-TW|zh-CN");
public static final TranslateMode ENGLISH2ARABIC = new TranslateMode("en|ar");
public static final TranslateMode ENGLISH2CHINESECN = new TranslateMode("en|zh-CN");
public static final TranslateMode ENGLISH2CHINESETW = new TranslateMode("en|zh-TW");
public static final TranslateMode ENGLSISH2FRENCH = new TranslateMode("en|fr");
public static final TranslateMode ENGLISH2GERMAN= new TranslateMode("en|de");
public static final TranslateMode ENGLISH2ITALIAN= new TranslateMode("en|it");
public static final TranslateMode ENGLISH2JAPANESE= new TranslateMode("en|ja");
public static final TranslateMode ENGLISH2KOREAN= new TranslateMode("en|ko");
public static final TranslateMode ENGLISH2PORTUGUESE= new TranslateMode("en|pt");
public static final TranslateMode ENGLISH2RUSSIAN = new TranslateMode("en|ru");
public static final TranslateMode ENGLISH2SPANISH = new TranslateMode("en|es");
public static final TranslateMode FRANCH2ENGLISH = new TranslateMode("fr|en");
public static final TranslateMode FRENCH2GERMAN = new TranslateMode("fr|de");
public static final TranslateMode GERMAN2ENGLISH = new TranslateMode("de|en");
public static final TranslateMode GERMAN2FRANCH = new TranslateMode("de|fr");
public static final TranslateMode ITALIAN2ENGLISH = new TranslateMode("it|en");
public static final TranslateMode JAPANESE2ENGLISH= new TranslateMode("ja|en");
public static final TranslateMode KOREAN2ENGLISH = new TranslateMode("ko|en");
public static final TranslateMode PORTUGUESE2ENGLISH = new TranslateMode("pt|en");
public static final TranslateMode RUSSIAN2ENGLISH = new TranslateMode("ru|en");
public static final TranslateMode SPANISH2ENGLISH = new TranslateMode("es|en");

public String toString() {
return langpair;
}

private final String langpair;

private TranslateMode(String mode) {
langpair = mode;
}
}


No comments: