use of com.google.cloud.translate.Translate.LanguageListOption 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.Translate.LanguageListOption in project google-cloud-java by GoogleCloudPlatform.
the class TranslateTest method testListOptions.
@Test
public void testListOptions() {
// target language
LanguageListOption listOption = LanguageListOption.targetLanguage(LANGUAGE);
assertEquals(TranslateRpc.Option.TARGET_LANGUAGE, listOption.getRpcOption());
assertEquals(LANGUAGE, listOption.getValue());
}
Aggregations