use of com.google.cloud.translate.Language in project google-cloud-java by GoogleCloudPlatform.
the class ITTranslateTest method testListSupportedLanguagesWithOptions.
@Test
public void testListSupportedLanguagesWithOptions() {
Set<String> supportedLanguages = new HashSet<>();
List<Language> languages = TRANSLATE.listSupportedLanguages(LanguageListOption.targetLanguage("es"));
for (Language language : languages) {
supportedLanguages.add(language.getCode());
assertNotNull(language.getName());
}
for (String code : LANGUAGES) {
assertTrue(supportedLanguages.contains(code));
}
}
use of com.google.cloud.translate.Language in project google-cloud-java by GoogleCloudPlatform.
the class ITTranslateTest method testListSupportedLanguages.
@Test
public void testListSupportedLanguages() {
Set<String> supportedLanguages = new HashSet<>();
List<Language> languages = TRANSLATE.listSupportedLanguages();
for (Language language : languages) {
supportedLanguages.add(language.getCode());
assertNotNull(language.getName());
}
for (String code : LANGUAGES) {
assertTrue(supportedLanguages.contains(code));
}
}
use of com.google.cloud.translate.Language in project java-docs-samples by GoogleCloudPlatform.
the class TranslateText method displaySupportedLanguages.
/**
* Displays a list of supported languages and codes.
*
* @param out print stream
* @param tgtLang optional target language
*/
public static void displaySupportedLanguages(PrintStream out, Optional<String> tgtLang) {
Translate translate = createTranslateService();
LanguageListOption target = LanguageListOption.targetLanguage(tgtLang.orElse("en"));
List<Language> languages = translate.listSupportedLanguages(target);
for (Language language : languages) {
out.printf("Name: %s, Code: %s\n", language.getName(), language.getCode());
}
}
use of com.google.cloud.translate.Language in project google-cloud-java by GoogleCloudPlatform.
the class ITTranslateSnippets method testListSupportedLanguages.
@Test
public void testListSupportedLanguages() {
// [START translate_list_codes]
// TODO(developer): Uncomment these lines.
// import com.google.cloud.translate.*;
// Translate translate = TranslateOptions.getDefaultInstance().getService();
List<Language> languages = translate.listSupportedLanguages();
for (Language language : languages) {
System.out.printf("Name: %s, Code: %s\n", language.getName(), language.getCode());
}
// [END translate_list_codes]
Set<String> supportedLanguages = new HashSet<>();
for (Language language : languages) {
supportedLanguages.add(language.getCode());
assertNotNull(language.getName());
}
for (String code : LANGUAGES) {
assertTrue(supportedLanguages.contains(code));
}
}
use of com.google.cloud.translate.Language in project google-cloud-java by GoogleCloudPlatform.
the class ITTranslateSnippets method testListSupportedLanguagesWithTarget.
@Test
public void testListSupportedLanguagesWithTarget() {
// [START translate_list_language_names]
// TODO(developer): Uncomment these lines.
// import com.google.cloud.translate.*;
// Translate translate = TranslateOptions.getDefaultInstance().getService();
List<Language> languages = translate.listSupportedLanguages(Translate.LanguageListOption.targetLanguage("es"));
for (Language language : languages) {
System.out.printf("Name: %s, Code: %s\n", language.getName(), language.getCode());
}
// [END translate_list_language_names]
Set<String> supportedLanguages = new HashSet<>();
for (Language language : languages) {
supportedLanguages.add(language.getCode());
assertNotNull(language.getName());
}
for (String code : LANGUAGES) {
assertTrue(supportedLanguages.contains(code));
}
}
Aggregations