Skip to content

Commit

Permalink
Merge branch 'master' into java-quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
lesv authored Nov 17, 2016
2 parents 5d07f6f + 7e81ef5 commit 7017ddf
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "java-repo-tools"]
path = java-repo-tools
url = https://github.com/GoogleCloudPlatform/java-repo-tools.git
1 change: 0 additions & 1 deletion java-repo-tools
Submodule java-repo-tools deleted from 74755a
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
5 changes: 1 addition & 4 deletions travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ shellcheck ./**/*.sh

# Run tests using App Engine local devserver.
test_localhost() {
# The testing scripts are stored in a submodule. This allows us to carefully
# update the testing scripts, since submodules are tied to a specific commit.
git submodule init
git submodule update
git clone https://github.com/GoogleCloudPlatform/java-repo-tools.git

devserver_tests=(
appengine/helloworld
Expand Down

0 comments on commit 7017ddf

Please sign in to comment.