Translates documents in synchronous mode.
HTTP request
POST https://{TRANSLATION_GDC_ENDPOINT}/v3/{parent}:translateDocument
Path parameters
Parameters | |
---|---|
parent |
Required. Location to make a regional call. Format: For global calls, use Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have the same location-id), otherwise an INVALID_ARGUMENT (400) error is returned. |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "sourceLanguageCode": string, "targetLanguageCode": string, "documentInputConfig": { object ( |
Fields | |
---|---|
sourceLanguageCode |
Optional. The ISO-639 language code of the input document if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response. Source language must be specified if the request contains a glossary or a custom model. |
targetLanguageCode |
Required. The ISO-639 language code to use for translation of the input document, set to one of the language codes listed in Language Support. |
documentInputConfig |
Required. Input configurations. |
glossaryConfig |
Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned. Authorization requires the following IAM permission on the specified resource
|
Response body
A translated document response message.
If successful, the response body contains data with the following structure:
JSON representation |
---|
{ "documentTranslation": { object ( |
Fields | |
---|---|
documentTranslation |
Translated document. |
glossaryDocumentTranslation |
The document's translation output if a glossary is provided in the request. This can be the same as [TranslateDocumentResponse.document_translation] if no glossary terms apply. |
glossaryConfig |
The |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-translation
https://www.googleapis.com/auth/cloud-platform
DocumentInputConfig
A document translation request input config.
JSON representation |
---|
{
"mimeType": string,
"content": string,
"S3Source": {
object ( |
Fields | |
---|---|
mimeType |
Specifies the input document's mimeType. If not specified it will be determined using the file extension for S3Source provided files. For a file provided through bytes content the mimeType must be provided. Currently supported mime types are:
Supported file formats are:
|
content |
Document's content represented as a stream of bytes. A base64-encoded string. |
S3Source |
The storage location for the input content. |
DocumentTranslation
A translated document message.
JSON representation |
---|
{ "byteStreamOutputs": [ string ], "mimeType": string, "detectedLanguageCode": string } |
Fields | |
---|---|
byteStreamOutputs[] |
The array of translated documents. It is expected to be size 1 for now. We may produce multiple translated documents in the future for other type of file formats. A base64-encoded string. |
mimeType |
The translated document's mime type. |
detectedLanguageCode |
The detected language for the input document. If the user did not provide the source language for the input document, this field will have the language code automatically detected. If the source language was passed, auto-detection of the language does not occur and this field is empty. |