我建议你看看谷歌的API服务,翻译-V2在这里: https://developers.google.com/api-client-library/java/apis/translate/v2
基本上,如果你使用Maven,你必须添加这种依赖性:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-translate</artifactId>
<version>v2-rev48-1.22.0</version>
</dependency>
然后你可以使用它:
TranslateRequestInitializer translateRequestInitializer = new TranslateRequestInitializer(
"Generated key from google console");
// Set up the HTTP transport and JSON factory
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
// set up translate
final Translate translate = new Translate.Builder(httpTransport, jsonFactory, null)
.setApplicationName("My Apps").setTranslateRequestInitializer(translateRequestInitializer).build();
List<String> sourceTextList = Arrays.asList("source Text");
// translate
System.out.println(translate.translations().list(sourceTextList, "fr").execute());
你可以在这里找到样本:https://developers.google.com/api-client-library/java/google-api-java-client/samples
的可能的复制[如何使用谷歌翻译API在我的Java应用程序?(http://stackoverflow.com/questions/8147284/how-to-use-google-translate-api-in-my-java-application ) –