Translate API v2, REST: Translation.Translate

Translates the text to the specified language.

HTTP request

POST https://translate.api.cloud.yandex.net/translate/v2/translate
        

Body parameters

{
          "sourceLanguageCode": "string",
          "targetLanguageCode": "string",
          "format": "string",
          "texts": [
            "string"
          ],
          "folderId": "string",
          "model": "string",
          "glossaryConfig": {
            // Includes only one of the fields `glossaryData`
            "glossaryData": {
              "glossaryPairs": [
                {
                  "sourceText": "string",
                  "translatedText": "string",
                  "exact": "boolean"
                }
              ]
            }
            // end of the list of possible fields
          },
          "speller": "boolean"
        }
        

Field

Description

sourceLanguageCode

string

The text language to translate from.
Most languages are specified in ISO 639-1 format (for example, ru), but the field are not limited to it.

Required for translating with glossary.

targetLanguageCode

string

Required field. The target language to translate the text.
Most languages are specified in ISO 639-1 format (for example, ru), but the field are not limited to it.

format

enum (Format)

Format of the text to be translated.

  • FORMAT_UNSPECIFIED
  • PLAIN_TEXT: Text without markup. Default value.
  • HTML: Text in the HTML format.

texts[]

string

Array of the strings to translate.
The maximum total length of all strings is 10000 characters.

folderId

string

ID of the folder to which you have access.
Required for authorization with a user account.
Do not specify this field if you make the request on behalf of a service account.

model

string

Model ID if you use custom model.

glossaryConfig

TranslateGlossaryConfig

Glossary to be applied for the translation. For more information, see Glossaries.

speller

boolean

Enable spell checking.

TranslateGlossaryConfig

Field

Description

glossaryData

GlossaryData

Pass glossary data in the request. Currently, the only way to pass glossary.

Includes only one of the fields glossaryData.

GlossaryData

Field

Description

glossaryPairs[]

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.

GlossaryPair

Field

Description

sourceText

string

Required field. Text in the source language.

translatedText

string

Required field. Text in the target language.

exact

boolean

Allows to add translations for specific terms to neuroglossaries.

Response

HTTP Code: 200 - OK

{
          "translations": [
            {
              "text": "string",
              "detectedLanguageCode": "string"
            }
          ]
        }
        

Field

Description

translations[]

TranslatedText

Array of the translations.

TranslatedText

Field

Description

text

string

Translated text.

detectedLanguageCode

string

The language code of the source text.
Most languages are specified in ISO 639-1 format (for example, ru), but the field are not limited to it.

Предыдущая
Следующая