Skip to content

Instantly share code, notes, and snippets.

@osima
Created June 28, 2010 00:18
Show Gist options
  • Select an option

  • Save osima/455295 to your computer and use it in GitHub Desktop.

Select an option

Save osima/455295 to your computer and use it in GitHub Desktop.
Google翻訳APIの中継サーブレット
import com.google.api.translate.*
LANG_SRC =Language.JAPANESE
LANG_DEST =Language.ENGLISH
//LANG_DEST =Language.FRENCH
//LANG_DEST =Language.GERMAN
//LANG_DEST =Language.CHINESE_SIMPLIFIED
request.setCharacterEncoding("UTF-8")
response.setContentType("text/plain; charset=UTF-8")
def text = request.getParameter("query")
if( text ){
Translate.setHttpReferrer("http://code.google.com/p/google-api-translate-java/")
println Translate.execute(text, LANG_SRC, LANG_DEST)
}
else{
println 'NG'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment