See: Description
Interface | Description |
---|---|
Translate |
An interface for Google Translation.
|
TranslateFactory |
An interface for Translates factories.
|
Class | Description |
---|---|
Detection |
Information about a language detection.
|
Language |
Information about a language supported by Google Translation.
|
Translate.LanguageListOption |
Class for specifying supported language listing options.
|
Translate.TranslateOption |
Class for specifying translate options.
|
TranslateOptions | |
TranslateOptions.Builder | |
TranslateOptions.DefaultTranslateFactory | |
TranslateOptions.DefaultTranslateRpcFactory | |
Translation |
Information about a translation.
|
Exception | Description |
---|---|
TranslateException |
Google Translation service exception.
|
Here's a simple usage example for Google Cloud Translation. This example shows how to detect
the language of some text and how to translate some text. The example assumes that either
Application Default Credentials are available or that the GOOGLE_API_KEY
environment
variable is set and contains a valid API key. Alternatively, you can use setCredentials
to set credentials, or
TranslateOptions.Builder.setApiKey(java.lang.String)
to set an
API key. For the complete source code see
DetectLanguageAndTranslate.java.
Translate translate = TranslateOptions.getDefaultInstance().getService();
Detection detection = translate.detect("Hola");
String detectedLanguage = detection.getLanguage();
Translation translation = translate.translate(
"World",
TranslateOption.sourceLanguage("en"),
TranslateOption.targetLanguage(detectedLanguage));
System.out.printf("Hola %s%n", translation.getTranslatedText());
Copyright © 2022 Google LLC. All rights reserved.