Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nits #415

Merged
merged 6 commits into from
Nov 16, 2016
Merged

Nits #415

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Removes references to deprecated methods
  • Loading branch information
gguuss committed Nov 15, 2016
commit d299ebc520d0ef3d72bc65fd00d0b7c4c112e2a3
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void detectLanguage(String sourceText, PrintStream out) {
}

/**
* Translates the source text in any language to english.
* Translates the source text in any language to English.
*
* @param sourceText source text to be translated
* @param out print stream
Expand All @@ -56,7 +56,7 @@ public static void translateText(String sourceText, PrintStream out) {
Translate translate = createTranslateService();
Translation translation = translate.translate(sourceText);
out.printf("Source Text:\n\t%s\n", sourceText);
out.printf("Translated Text:\n\t%s\n", translation.translatedText());
out.printf("Translated Text:\n\t%s\n", translation.getTranslatedText());
}

/**
Expand All @@ -79,7 +79,7 @@ public static void translateTextWithOptions(

Translation translation = translate.translate(sourceText, srcLang, tgtLang);
out.printf("Source Text:\n\tLang: %s, Text: %s\n", sourceLang, sourceText);
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.translatedText());
out.printf("TranslatedText:\n\tLang: %s, Text: %s\n", targetLang, translation.getTranslatedText());
}

/**
Expand All @@ -94,7 +94,7 @@ public static void displaySupportedLanguages(PrintStream out, Optional<String> t
List<Language> languages = translate.listSupportedLanguages(target);

for (Language language : languages) {
out.printf("Name: %s, Code: %s\n", language.name(), language.code());
out.printf("Name: %s, Code: %s\n", language.getName(), language.getCode());
}
}

Expand All @@ -104,23 +104,23 @@ public static void displaySupportedLanguages(PrintStream out, Optional<String> t
* @return Google Translate Service
*/
public static Translate createTranslateService() {
TranslateOptions translateOption = TranslateOptions.builder()
.retryParams(retryParams())
.connectTimeout(60000)
.readTimeout(60000)
TranslateOptions translateOption = TranslateOptions.newBuilder()
.setRetryParams(retryParams())
.setConnectTimeout(60000)
.setReadTimeout(60000)
.build();
return translateOption.service();
return translateOption.getService();
}

/**
* Retry params for the Translate API.
*/
private static RetryParams retryParams() {
return RetryParams.builder()
.retryMaxAttempts(3)
.maxRetryDelayMillis(30000)
.totalRetryPeriodMillis(120000)
.initialRetryDelayMillis(250)
return RetryParams.newBuilder()
.setRetryMaxAttempts(3)
.setMaxRetryDelayMillis(30000)
.setTotalRetryPeriodMillis(120000)
.setInitialRetryDelayMillis(250)
.build();
}

Expand Down