Created
June 28, 2010 00:18
-
-
Save osima/455295 to your computer and use it in GitHub Desktop.
Google翻訳APIの中継サーブレット
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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