我正在使用此代码:
GttService myService = new GttService("ex1cor.ex1Ap.1");
myService.setUserCredentials("example@gmail.com", "password");
DocumentEntry entry = new DocumentEntry();
// Set source language
String srcLang = "en";
entry.setSourceLanguage(new SourceLanguage(srcLang));
// Set target language
String targetLang = "ja";
entry.setTargetLanguage(new TargetLanguage(targetLang));
// Set title
String title = "Test";
entry.setTitle(new PlainTextConstruct(title));
// Set local file for upload.
String filename = "D:\\translate\\english.txt";
File file = new File(filename);
String mimeType = "text/plain";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
entry.setContent(content);
URL feedUrl = new URL("http://translate.google.com/toolkit/feeds/documents");
DocumentEntry resultEntry = myService.insert(feedUrl, entry);
什么都没发生。没有错误......什么都没有!
答案 0 :(得分:1)
Google Translator Toolkit API不提供文档翻译服务。它目前仅提供文档管理。如果您想要翻译某些内容,可能需要查看this。它工作得很好,但它有一些缺陷。例如,文档的限制为5000个字符。这个API不会处理它,因为它不是主要用于文档翻译,而是用于翻译许多小文本。