Class Translate.TranslateOption (2.22.0)

public static class Translate.TranslateOption extends Option

Class for specifying translate options.

Inheritance

java.lang.Object > com.google.cloud.translate.Option > Translate.TranslateOption

Static Methods

format(String format)

public static Translate.TranslateOption format(String format)

Sets the format of the source text, in either HTML (default) or plain-text. A value of html indicates HTML and a value of text indicates plain-text.

Parameter
NameDescription
formatString

the format of the source text

Returns
TypeDescription
Translate.TranslateOption

model(String model)

public static Translate.TranslateOption model(String model)

Sets the language translation model. You can use this parameter to take advantage of Neural Machine Translation. Possible values are base and nmt. Google Translation could use a different model to translate your text: use Translation#getModel() to know which model was used for translation. Please note that you must be whitelisted to use this option, otherwise translation will fail.

Parameter
NameDescription
modelString

the language translation model

Returns
TypeDescription
Translate.TranslateOption

sourceLanguage(String sourceLanguage)

public static Translate.TranslateOption sourceLanguage(String sourceLanguage)

Returns an option for setting the source language. If not provided, Google Translation will try to detect the language of the text to translate.

Parameter
NameDescription
sourceLanguageString

the source language code

Returns
TypeDescription
Translate.TranslateOption

targetLanguage(String targetLanguage)

public static Translate.TranslateOption targetLanguage(String targetLanguage)

Returns an option for setting the target language. If this option is not provided, the value returned by TranslateOptions#getTargetLanguage() is used.

Parameter
NameDescription
targetLanguageString

the target language code

Returns
TypeDescription
Translate.TranslateOption