Class Translate.TranslateOption (2.42.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
Name Description
format String

the format of the source text

Returns
Type Description
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
Name Description
model String

the language translation model

Returns
Type Description
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
Name Description
sourceLanguage String

the source language code

Returns
Type Description
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
Name Description
targetLanguage String

the target language code

Returns
Type Description
Translate.TranslateOption