Translate API v2, gRPC: TranslationService
Written by
Updated at December 13, 2022
A set of methods for the Translate service.
Call | Description |
---|---|
Translate | Translates the text to the specified language. |
DetectLanguage | Detects the language of the text. |
ListLanguages | Retrieves the list of supported languages. |
Calls TranslationService
Translate
Translates the text to the specified language.
rpc Translate (TranslateRequest) returns (TranslateResponse)
TranslateRequest
Field | Description |
---|---|
source_language_code | string The text language to translate from. Specified in ISO 639-1 ru ). Required for translating with glossary. The maximum string length in characters is 3. |
target_language_code | string Required. The target language to translate the text. Specified in ISO 639-1 en ). The maximum string length in characters is 3. |
format | enum Format Format of the text.
|
texts[] | string Array of the strings to translate. The maximum total length of all strings is 10000 characters. The number of elements must be greater than 0. |
folder_id | string ID of the folder to which you have access. Required for authorization with a user account (see yandex.cloud.iam.v1.UserAccount resource). Don't specify this field if you make the request on behalf of a service account. The maximum string length in characters is 50. |
model | string Do not specify this field, custom models are not supported yet. The maximum string length in characters is 50. |
glossary_config | TranslateGlossaryConfig Glossary to be applied for the translation. For more information, see Glossaries. |
speller | bool use speller |
TranslateGlossaryConfig
Field | Description |
---|---|
glossary_source | oneof: glossary_data |
glossary_data | GlossaryData Pass glossary data in the request. Currently, only this way to pass glossary is supported. |
GlossaryData
Field | Description |
---|---|
glossary_pairs[] | GlossaryPair Array of text pairs. The maximum total length of all source texts is 10000 characters. The maximum total length of all translated texts is 10000 characters. The number of elements must be in the range 1-50. |
GlossaryPair
Field | Description |
---|---|
source_text | string Required. Text in the source language. |
translated_text | string Required. Text in the target language. |
exact | bool |
TranslateResponse
Field | Description |
---|---|
translations[] | TranslatedText Array of the translations. |
TranslatedText
Field | Description |
---|---|
text | string Translated text. |
detected_language_code | string The language code of the source text. Specified in ISO 639-1 en ). |
DetectLanguage
Detects the language of the text.
rpc DetectLanguage (DetectLanguageRequest) returns (DetectLanguageResponse)
DetectLanguageRequest
Field | Description |
---|---|
text | string Required. The text to detect the language for. The maximum string length in characters is 1000. |
language_code_hints[] | string List of the most likely languages. These languages will be given preference when detecting the text language. Specified in ISO 639-1 ru ). To get the list of supported languages, use a TranslationService.ListLanguages request. The maximum number of elements is 10. The maximum string length in characters for each value is 3. |
folder_id | string ID of the folder to which you have access. Required for authorization with a user account (see yandex.cloud.iam.v1.UserAccount resource). Don't specify this field if you make the request on behalf of a service account. The maximum string length in characters is 50. |
DetectLanguageResponse
Field | Description |
---|---|
language_code | string The text language in ISO 639-1 ru ). To get the language name, use a TranslationService.ListLanguages request. |
ListLanguages
Retrieves the list of supported languages.
rpc ListLanguages (ListLanguagesRequest) returns (ListLanguagesResponse)
ListLanguagesRequest
Field | Description |
---|---|
folder_id | string ID of the folder to which you have access. Required for authorization with a user account (see yandex.cloud.iam.v1.UserAccount resource). Don't specify this field if you make the request on behalf of a service account. The maximum string length in characters is 50. |
ListLanguagesResponse
Field | Description |
---|---|
languages[] | Language List of supported languages. |
Language
Field | Description |
---|---|
code | string The language code. Specified in ISO 639-1 en ). |
name | string The name of the language (for example, English ). |