2011년 1월 25일 화요일

[Android Course][English][Theme] -"Google Translation (Google Translate) API " translated by




Google Translation (Google Translate) API by making a simple translator, let's see.

1. "Google Translate" library Download.
: Google Translate API to use is a priority need to add external libraries.
Visit the following sites will receive the appropriate library files.

http://code.google.com/p/google-api-translate-java/downloads/list

2. Project added to the library
: "Project - Properties - Java Build Path - Libraries - Add JARs ..."
ex) Add the downloaded jar file => google-api-translate-java-0.92.jar

3. Permission (permission) settings
: "AndroidManifest.xml" added to the file permissions.


4. Example : Java Source Code























public void ExeConnection() {
// "Str" : Translate a sentence or word
String str = m_Search_EditText.getText().toString();
// "getstr" : Translated phrase or word
String getstr = new String();

try{
Translate.setHttpReferrer("http://androidhuman.tistory.com");
/ / translated running
getstr = Translate.execute(str, Language.KOREAN, Language.ENGLISH);
}catch(Exception e){
e.printStackTrace();
}
m_View_TextView.setText(getstr);
}

5. Description
- public String execute(String text, Language from, Language to)
: From language to language into written text to a string.
Returns the translated text.
To translate the language of the sentence if it is not fixed auto-sensing (Language.AUTO_DETECT) can be used.

- Translate.setHttpReferrer
: Before using the API translation is the method I need to write.
URL of your blog or other site, please put the address is.
(If you miss the code does not perform the translation.)

In addition, inquiries, or questions, please contact us.
(joonryang@gmail.com)

댓글 없음:

댓글 쓰기