Skip to content

Nits #415

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

Merged
merged 6 commits into from
Nov 16, 2016
Merged

Nits #415

Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion translate/cloud-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
-->
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>come.example.translate</groupId>
<groupId>com.example.translate</groupId>
<artifactId>translate-google-cloud-samples</artifactId>
<packaging>jar</packaging>

Expand Down
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,12 +56,12 @@ 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());
}

/**
* Translate the source text from source to target language.
* Make sure that your project is whitelisted.
* Make sure that your project is whitelisted.
*
* @param sourceText source text to be translated
* @param sourceLang source language of the text
Expand All @@ -83,7 +83,8 @@ public static void translateTextWithOptionsAndModel(

Translation translation = translate.translate(sourceText, srcLang, tgtLang, model);
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 @@ -107,7 +108,8 @@ 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.translatedText());
}

/**
Expand All @@ -122,7 +124,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 @@ -132,23 +134,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