|
32 | 32 | import com.google.api.services.translate.model.DetectionsResourceItems; |
33 | 33 | import com.google.api.services.translate.model.LanguagesListResponse; |
34 | 34 | import com.google.api.services.translate.model.LanguagesResource; |
35 | | -import com.google.api.services.translate.model.TranslationsListResponse; |
36 | 35 | import com.google.api.services.translate.model.TranslationsResource; |
37 | 36 | import com.google.cloud.translate.TranslateException; |
38 | 37 | import com.google.cloud.translate.TranslateOptions; |
@@ -118,18 +117,19 @@ public List<LanguagesResource> listSupportedLanguages(Map<Option, ?> optionMap) |
118 | 117 | @Override |
119 | 118 | public List<TranslationsResource> translate(List<String> texts, Map<Option, ?> optionMap) { |
120 | 119 | try { |
121 | | - // TODO use POST as soon as usage of "model" causes error in non-whitelisted projects |
122 | | - String targetLanguage = |
123 | | - firstNonNull(TARGET_LANGUAGE.getString(optionMap), options.getTargetLanguage()); |
124 | | - final String sourceLanguage = SOURCE_LANGUAGE.getString(optionMap); |
125 | | - List<TranslationsResource> translations = |
126 | | - translate.translations() |
127 | | - .list(texts, targetLanguage) |
128 | | - .setSource(sourceLanguage) |
129 | | - .setKey(options.getApiKey()) |
130 | | - .set("model", MODEL.getString(optionMap)) |
131 | | - .execute() |
132 | | - .getTranslations(); |
| 120 | + // TODO use POST as soon as usage of "model" correctly reports an error in non-whitelisted |
| 121 | + // projects |
| 122 | + String targetLanguage = |
| 123 | + firstNonNull(TARGET_LANGUAGE.getString(optionMap), options.getTargetLanguage()); |
| 124 | + final String sourceLanguage = SOURCE_LANGUAGE.getString(optionMap); |
| 125 | + List<TranslationsResource> translations = |
| 126 | + translate.translations() |
| 127 | + .list(texts, targetLanguage) |
| 128 | + .setSource(sourceLanguage) |
| 129 | + .setKey(options.getApiKey()) |
| 130 | + .set("model", MODEL.getString(optionMap)) |
| 131 | + .execute() |
| 132 | + .getTranslations(); |
133 | 133 | return Lists.transform( |
134 | 134 | translations != null ? translations : ImmutableList.<TranslationsResource>of(), |
135 | 135 | new Function<TranslationsResource, TranslationsResource>() { |
|
0 commit comments