Translate documents  |  Cloud Translation  |  Google Cloud (2023)

Cloud Translation - Advanced provides a Document Translation API fordirectly translating formatted documents such as PDF and DOCX. Compared toplain text translations, Document Translation preserves the originalformatting and layout in your translated documents, helping you retain much ofthe original context like paragraph breaks.

The following sections describe how to translate documents and useDocument Translation with other Cloud Translation - Advanced features likeglossaries and AutoML Translation models. Document Translationsupports both online and batch translation requests.

For plain text and HTML translations, see Translatingtext.

Supported file formats

Document Translation support the following input file types and theirassociated output file types.

Inputs Document MIME type Output
DOCX* application/vnd.openxmlformats-officedocument.wordprocessingml.document DOCX
PDF application/pdf PDF, DOCX
PPTX application/vnd.openxmlformats-officedocument.presentationml.presentation PPTX
XLSX application/vnd.openxmlformats-officedocument.spreadsheetml.sheet XLSX

*Content inside text boxes aren't translated and remain inthe source language.

Document Translation supports both native andscanned PDF documents with some differences. For optimal formathandling, use native PDF files when possible. Translating scanned PDF filesresults in some formatting loss. Complex PDF layouts can also result in someformatting loss, which can include data tables, multi-column layouts, and graphswith labels or legends.

If you have PDF content in the DOCX or PPTX format, we recommend that youtranslate content by using those formats before converting them to PDFs. Ingeneral, Document Translation preserves a document's layout and styleof DOCX and PPTX files better than PDF files. After a document translation, youcan then convert the results to PDF files.

Native and scanned PDF document translations

Document Translation supports both native and scanned PDF files,including translations to or from right-to-left languages. Support for PDF toDOCX conversions is available for batch document translations on nativePDF files only. Also, Document Translation preserves hyperlinks, fontsize, font color, and font style for native PDF files only (for both synchronousand batch translations).

Before you begin

Before you can start using the Cloud Translation API, you must have a project that hasthe Cloud Translation API enabled, and you must have a private key with the appropriatecredentials. You can also install client libraries for common programminglanguages to help you make calls to the API. For more information, see the Setup page.

Required permissions

For requests that require Cloud Storage access, such as batchDocument Translation, you might require Cloud Storage permissions toread input files or send output files to a bucket. For example, to read inputfiles from a bucket, you must have at least read object permissions (provided bythe role roles/storage.objectViewer) on the bucket. For more information aboutCloud Storage roles, see the Cloud Storagedocumentation.

Translate documents (online)

Online translation provides real-time processing (synchronous processing) of asingle file. For PDFs, the file size can be up to 20 MB and up to 20 pages. Forother document types, the file sizes can be up to 20 MB with no page limits.

Translate a document from Cloud Storage

The following example translates a file from a Cloud Storage bucket andoutputs the result to a Cloud Storage bucket. The response also returns abyte stream. You can specify the MIME type; if you don't,Document Translation determines it by using the input file's extension.

If you don't specify a source language code, Document Translationdetects the language for you. The detected language is included in the output inthe detectedLanguageCode field.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation. For example, us-central1.
  • SOURCE_LANGUAGE: (Optional) The language code of the input document. If known, set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language to translate the input document to. Set to one of the language codes listed in Language support.
  • INPUT_FILE_PATH: The Cloud Storage location and file name of the input document.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where the output document will be stored.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_code": "TARGET_LANGUAGE", "document_input_config": { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH" } }, "document_output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }}

To send your request, expand one of these options:

(Video) Using Cloud Translation to translate global content with Eli Lilly

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{ "documentTranslation": { "byteStreamOutputs": ["BYTE_STREAM"], "mimeType": "MIME_TYPE" }, "model": "projects/PROJECT_NUMBER/locations/LOCATION/models/general/nmt"}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Translation quickstart using client libraries. For more information, see the Translation Node.js API reference documentation.

View on GitHub Feedback

/** * TODO(developer): Uncomment these variables before running the sample. */// const projectId = 'YOUR_PROJECT_ID';// const location = 'global';// const inputUri = 'path_to_your_file';// Imports the Google Cloud Translation libraryconst {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;// Instantiates a clientconst translationClient = new TranslationServiceClient();const documentInputConfig = { gcsSource: { inputUri: inputUri, },};async function translateDocument() { // Construct request const request = { parent: translationClient.locationPath(projectId, location), documentInputConfig: documentInputConfig, sourceLanguageCode: 'en-US', targetLanguageCode: 'sr-Latn', }; // Run request const [response] = await translationClient.translateDocument(request); console.log( `Response: Mime Type - ${response.documentTranslation.mimeType}` );}translateDocument();

Translate a document inline

The following example sends a document inline as part of the request. You mustinclude the MIME type for inline document translations.

If you don't specify a source language code, Document Translationdetects the language for you. The detected language is included in the output inthe detectedLanguageCode field.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation. For example, us-central1.
  • SOURCE_LANGUAGE: (Optional) The language code of the input document. If known, set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language to translate the input document to. Set to one of the language codes listed in Language support.
  • MIME_TYPE: The format of the source document, such as application/pdf.
  • INPUT_BYTE_STREAM: The input document's content represented as a stream of bytes.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where the output document will be stored.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_code": "TARGET_LANGUAGE", "document_input_config": { "mimeType": "MIME_TYPE", "content": "INPUT_BYTE_STREAM" }, "document_output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

(Video) How To Translate Documents Into Different Languages | Google Cloud Translation API | PHP | WordPress

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{ "documentTranslation": { "byteStreamOutputs": ["BYTE_STREAM"], "mimeType": "MIME_TYPE" }, "model": "projects/PROJECT_NUMBER/locations/LOCATION/models/general/nmt"}

Python

Before trying this sample, follow the Python setup instructions in the Translation quickstart using client libraries. For more information, see the Translation Python API reference documentation.

View on GitHub Feedback

from google.cloud import translate_v3beta1 as translatedef translate_document(project_id: str, file_path: str): client = translate.TranslationServiceClient() location = "us-central1" parent = f"projects/{project_id}/locations/{location}" # Supported file types: https://cloud.google.com/translate/docs/supported-formats with open(file_path, "rb") as document: document_content = document.read() document_input_config = { "content": document_content, "mime_type": "application/pdf", } response = client.translate_document( request={ "parent": parent, "target_language_code": "fr-FR", "document_input_config": document_input_config, } ) # To output the translated document, uncomment the code below. # f = open('/tmp/output', 'wb') # f.write(response.document_translation.byte_stream_outputs[0]) # f.close() # If not provided in the TranslationRequest, the translated file will only be returned through a byte-stream # and its output mime type will be the same as the input file's mime type print("Response: Detected Language Code - {}".format(response.document_translation.detected_language_code))

Use an AutoML model or a glossary

Instead of the Google-managed model, you can use your own AutoMLTranslation models to translate documents. In addition to specifying a model,you can also include a glossary to handle domain-specific terminology. If youspecify a model or a glossary, you must specify the source language. Thefollowing example uses an AutoML model and a glossary. If the model orglossary are in a different project, you must have the corresponding IAMpermission to access those resources.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation, such as us-central1. The location must match the region where your model, glossary, or both are located.
  • SOURCE_LANGUAGE: The language code of the input document. Set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language to translate the input document to. Set to one of the language codes listed in Language support.
  • INPUT_FILE_PATH: The Cloud Storage location and file name of the input document.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where the output document will be stored.
  • MODEL_PROJECT_ID: The project ID where the model is located.
  • MODEL_LOCATION: The region where the model is located.
  • MODEL_ID: The ID of the model to use.
  • GLOSSARY_PROJECT_ID: The project ID where the glossary is located.
  • GLOSSARY_LOCATION: The region where the glossary is located.
  • GLOSSARY_ID: The ID of the glossary to use.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_code": "TARGET_LANGUAGE", "document_input_config": { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH" } }, "document_output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }, "model": "projects/MODEL_PROJECT_ID/locations/MODEL_LOCATION/models/MODEL_ID", "glossary_config": { "glossary": "projects/GLOSSARY_PROJECT_ID/locations/MODEL_LOCATION/glossaries/GLOSSARY_ID" }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument" | Select-Object -Expand Content

You should receive a JSON response similar to the following:

{ "documentTranslation": { "byteStreamOutputs": ["BYTE_STREAM"], "mimeType": "MIME_TYPE" }, "glossary_document_translation": { "byteStreamOutputs": ["BYTE_STREAM_USING_GLOSSARY"], "mimeType": "MIME_TYPE" }, "model": "projects/MODEL_PROJECT_ID/locations/MODEL_LOCATION/models/MODEL_ID", "glossaryConfig": { "glossary": "projects/GLOSSARY_PROJECT_ID/locations/MODEL_LOCATION/glossaries/GLOSSARY_ID" }}

Translate documents (batch)

Batch translation allows you to translate multiple files into multiple languagesin a single request. For each request, you can send up to 100 files with a totalcontent size of up to 1 GB or 100 million Unicode codepoints, whichever limit ishit first. You can specify a particular translation model for each language.

(Video) How to translate Text Using Google cloud

Translate multiple documents

The following example includes multiple input configurations. Each inputconfiguration is a pointer to a file in a Cloud Storage bucket.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation. For example, us-central1.
  • SOURCE_LANGUAGE: The language code of the input documents. Set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language or languages to translate the input documents to. Use the language codes listed in Language support.
  • INPUT_FILE_PATH: The Cloud Storage location and file name of one or more input documents.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where all output documents are stored.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_codes": ["TARGET_LANGUAGE", ...], "input_configs": [ { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH_1" } }, { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH_2" } }, ... ], "output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument" | Select-Object -Expand Content

The response contains the ID for a [long-running operation](/translate/docs/advanced/long-running-operation).
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.translation.v3.BatchTranslateDocumentMetadata", "state": "RUNNING" }}

Node.js

Before trying this sample, follow the Node.js setup instructions in the Translation quickstart using client libraries. For more information, see the Translation Node.js API reference documentation.

View on GitHub Feedback

/** * TODO(developer): Uncomment these variables before running the sample. */// const projectId = 'YOUR_PROJECT_ID';// const location = 'us-central1';// const inputUri = 'path_to_your_files';// const outputUri = 'path_to_your_output_bucket';// Imports the Google Cloud Translation libraryconst {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;// Instantiates a clientconst translationClient = new TranslationServiceClient();const documentInputConfig = { gcsSource: { inputUri: inputUri, },};async function batchTranslateDocument() { // Construct request const request = { parent: translationClient.locationPath(projectId, location), documentInputConfig: documentInputConfig, sourceLanguageCode: 'en-US', targetLanguageCodes: ['sr-Latn'], inputConfigs: [ { gcsSource: { inputUri: inputUri, }, }, ], outputConfig: { gcsDestination: { outputUriPrefix: outputUri, }, }, }; // Batch translate documents using a long-running operation. // You can wait for now, or get results later. const [operation] = await translationClient.batchTranslateDocument(request); // Wait for operation to complete. const [response] = await operation.promise(); console.log(`Total Pages: ${response.totalPages}`);}batchTranslateDocument();

Python

Before trying this sample, follow the Python setup instructions in the Translation quickstart using client libraries. For more information, see the Translation Python API reference documentation.

View on GitHub Feedback

(Video) Google Cloud Translate API with DotNet | Google Cloud Translate API | Google.Cloud.Translation.V2

from google.cloud import translate_v3beta1 as translatedef batch_translate_document( input_uri: str, output_uri: str, project_id: str, timeout=180,): client = translate.TranslationServiceClient() # The ``global`` location is not supported for batch translation location = "us-central1" # Google Cloud Storage location for the source input. This can be a single file # (for example, ``gs://translation-test/input.docx``) or a wildcard # (for example, ``gs://translation-test/*``). # Supported file types: https://cloud.google.com/translate/docs/supported-formats gcs_source = {"input_uri": input_uri} batch_document_input_configs = { "gcs_source": gcs_source, } gcs_destination = {"output_uri_prefix": output_uri} batch_document_output_config = {"gcs_destination": gcs_destination} parent = f"projects/{project_id}/locations/{location}" # Supported language codes: https://cloud.google.com/translate/docs/language operation = client.batch_translate_document( request={ "parent": parent, "source_language_code": "en-US", "target_language_codes": ["fr-FR"], "input_configs": [batch_document_input_configs], "output_config": batch_document_output_config, } ) print("Waiting for operation to complete...") response = operation.result(timeout) print("Total Pages: {}".format(response.total_pages))

Translate and convert a native PDF file

The following example translates and converts a native PDF file to a DOCX file.You can specify multiple inputs of various file types; they don't all have to benative PDF files. However, scanned PDF files cannot be included when including aconversion; the request is rejected and no translations are done. Only nativePDF files are translated and converted to DOCX files. For example, if youinclude PPTX files, they are translated and returned as PPTX files.

If you regularly translate a mix of scanned and native PDF files, we recommendthat you organize them into separate Cloud Storage buckets. That way,when you request a batch translation and conversion, you can easily exclude thebucket that contains scanned PDF files instead of having to exclude individualfiles.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation. For example, us-central1.
  • SOURCE_LANGUAGE: The language code of the input documents. Set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language or languages to translate the input documents to. Use the language codes listed in Language support.
  • INPUT_FILE_PATH: The Cloud Storage location and file name of one or more native PDF files.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where all output documents are stored.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_codes": ["TARGET_LANGUAGE", ...], "input_configs": [ { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH_1" } }, { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH_2" } }, ... ], "output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }, "format_conversions": { "application/pdf": "application/vnd.openxmlformats-officedocument.wordprocessingml.document" }}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:batchTranslateDocument" | Select-Object -Expand Content

The response contains the ID for a [long-running operation](/translate/docs/advanced/long-running-operation).
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.translation.v3.BatchTranslateDocumentMetadata", "state": "RUNNING" }}

Use an AutoML model or a glossary

Instead of the Google-managed model, you can use your own AutoMLTranslation models to translate documents. In addition to specifying a model,you can also include a glossary to handle domain-specific terminology. If youspecify a model or a glossary, you must specify the source language. Thefollowing example uses an AutoML model and a glossary. You can specifyup to 10 target languages with their own model and glossary.

If you specify a model for some target languages and not others,Document Translation uses the Google-managed model for the unspecifiedlanguages. Similarly, if you specify a glossary for some target languages,Document Translation doesn't use any glossary for the unspecifiedlanguages.

REST

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER_OR_ID: Your Google Cloud project number or ID
  • LOCATION: Region where you want to run this operation, such as us-central1. The location must match the region where your model, glossary, or both are located.
  • SOURCE_LANGUAGE: The language code of the input documents. Set to one of the language codes listed in Language support.
  • TARGET_LANGUAGE: The target language or languages to translate the input documents to. Use the language codes listed in Language support.
  • INPUT_FILE_PATH: The Cloud Storage location and file name of one or more input documents.
  • OUTPUT_FILE_PREFIX: The Cloud Storage location where all output documents are stored.
  • MODEL_PROJECT_ID: The project ID where the model is located.
  • MODEL_LOCATION: The region where the model is located.
  • MODEL_ID: The ID of the model to use.
  • GLOSSARY_PROJECT_ID: The project ID where the glossary is located.
  • GLOSSARY_LOCATION: The region where the glossary is located.
  • GLOSSARY_ID: The ID of the glossary to use.

HTTP method and URL:

POST https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument

Request JSON body:

{ "source_language_code": "SOURCE_LANGUAGE", "target_language_codes": "[TARGET_LANGUAGE, ...]", "input_configs": [ { "gcsSource": { "inputUri": "gs://INPUT_FILE_PATH" } } ], "output_config": { "gcsDestination": { "outputUriPrefix": "gs://OUTPUT_FILE_PREFIX" } }, "models": { "TARGET_LANGUAGE": "projects/MODEL_PROJECT_ID/locations/MODEL_LOCATION/models/MODEL_ID", ... }, "glossaries": { "TARGET_LANGUAGE": { "glossary": "projects/GLOSSARY_PROJECT_ID/locations/MODEL_LOCATION/glossaries/GLOSSARY_ID" }, ... }}

To send your request, expand one of these options:

(Video) What is the Translation API?

curl (Linux, macOS, or Cloud Shell)

Save the request body in a file called request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument"

PowerShell (Windows)

Save the request body in a file called request.json, and execute the following command:

$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://translation.googleapis.com/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateDocument" | Select-Object -Expand Content

The response contains the ID for a long-running operation.
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.translation.v3.BatchTranslateDocumentMetadata", "state": "RUNNING" }}

What's next

  • Document Translation is priced per page. For more information, seePricing.

FAQs

Can Google Docs translate documents? ›

Translate a document

On your computer, open a document in Google Docs. Translate document. Enter a name for the translated document and select a language. Click Translate.

Is Google Cloud translate free? ›

The first 500,000 characters are free, and then you are charged for the additional 75,000 characters sent for detection, translation, or both.

Is Google Translate accurate for documents? ›

Yes, Google Translate is very accurate for the most part. In some cases, it's 94%+ accurate! In fact, it's one of the top-rated translation tools when it comes to translation accuracy, though the exact accuracy will depend on the language pairs that you've chosen.

Is there a program that can translate Documents? ›

1. Google Translate. Google Translate is the most famous Machine Translation service in the world.

Can Google Translate files? ›

In your browser, go to Google Translate. At the top, click Documents. Choose the languages to translate to and from. To automatically set the original language of a document, click Detect language.

Can Google Translate PDF files? ›

Google Translate PDF Files for Free

If you're unsure, you can set the input language to “Detect language.” Click “Choose File” and then the blue “Translate” button. Let Google work its magic. You'll get a pop-up with the PDF file translated.

Can Google Translate scanned Documents? ›

Things You Should Know. The Google Translate mobile can scan printed words and translate them into other languages.

Why is Google Translate Documents not working? ›

Google translate not working properly on Chrome might happen due to inappropriate browser settings configuration, language settings, third party extensions, or so.

Is Google Translate free or paid? ›

Google Translate is free.

An experienced professional translator can sometimes be costly, but remember you get what you pay for.

Is there a better free translator than Google? ›

DeepL is one of the best Google Translate alternatives for people who really value accuracy, especially when it comes to grasping context and local idioms. DeepL offers an API that you can use to automatically translate your website, as well as a web interface and apps to translate text content or text files (like .

Is Google Translate Offline free? ›

When you're traveling somewhere without access to the internet or don't want to use your data plan, you can still use the Google Translate app on Android and iOS when your phone is offline.

What happens to documents uploaded to Google Translate? ›

The moment you copy and paste any text into Google Translate, the content stops being yours. This means that your confidential information is no longer confidential.

What is the best program to Translate a document? ›

5 best machine translation software options in the market
  1. Google Translate. Google Translate needs no introduction, being probably the most well-known machine translation software out there. ...
  2. DeepL Translator. ...
  3. Bing Microsoft Translator. ...
  4. SYSTRAN Translate. ...
  5. Amazon Translate.
12 Jan 2022

Do professional translators use Google Translate? ›

The translation software that professional translators use is called a CAT tool, which stands for “computer-aided translation.” And while that might sound a lot like Google Translate at first glance, it isn't.

What app translates documents? ›

Scan & Translate app extracts texts from any printed sources: documents, books, signs, instructions or announcements and allows to immediately translate them to any of 90 languages.

How do I automatically translate a Word document? ›

Translate a whole file in Word
  1. Select Review > Translate > Translate Document.
  2. Select your language to see the translation.
  3. Select Translate. A copy of the translated document will be opened in a separate window.
  4. Select OK in the original window to close translator.

Can DeepL translate documents? ›

DeepL Translator allows you to not only type or paste text for translation, but also upload whole documents. Translating a document is extremely time efficient: All elements of the document, including body text, titles, captions, and even footnotes, will be translated into the language of your choice.

Can you automatically translate a PDF? ›

There's no automatic PDF translator, either. However, there is a simple workaround — just convert your PDF to an editable format, like a Word file, first.

How do I translate an entire PDF into another language? ›

Answered By: Client Services Jun 23, 2022 97223
  1. Go to Google Translate.
  2. Select Documents.
  3. Select Browse your computer to locate the document you want translated.
  4. To choose the language you want to translate to, click the Down arrow.
  5. Select Translate.

How do I translate a PDF attachment? ›

About This Article
  1. Go to https://www.onlinedoctranslator.com.
  2. Click Translate now.
  3. Click Upload file.
  4. Select the PDF.
  5. Click Open.
  6. Select languages.
  7. Click Translate.
  8. Click Download your translated document.
30 May 2022

Does Google have a free PDF converter? ›

PDF Convert - Convert Documents - Google Workspace Marketplace. Convert your Documents to PDF and vice-versa format for free. This software is free to use and will convert your documents into PDF and vice-versa within seconds.

Is there an app to translate PDF documents? ›

For those who need to translate PDFs often, perhaps it's worth installing the File Translator: PDF Translator mobile app. The app is free to use, but is available on Android only. To translate PDFs on your Android device using this app, open it and select File Translator.

Can Google translate a scanned PDF? ›

Steps to translate scanned PDF:

Open the Google Chrome browser and select Google Drive. Choose any pdf files from the drive or devices. Here we select a PDF file from our browser with Google docs. Open the Tools option and select translate documents.

Why is Google not automatically translating? ›

Try refreshing the webpage. If it's still not working, right-click anywhere on the page. Then, click Translate to [Language].

Is Google Translate still supported? ›

Google Translate is still available for very narrow purposes and use cases.

What is wrong with Google Translate? ›

“Beware of Safety” What?!

In short, firstly, Google Translate cannot recognise idioms, or cases where the same word may take a different meaning, depending on the context (mononyms). Secondly, there is no checking of the translation.

What is the cost of Google translator? ›

The Google translate is one of the best application for translation in any language. The best thing about Google translate is that it is free of cost, and it's user interface is also very attractive and smooth. It supports multiple languages, you can translate any language in which you want.

How much does it cost to use Google Translate? ›

How Google Translate Works. Google Translate is a free service provided by Google that translates words, phrases, and even entire texts in over 100 languages.

Can you use Google Translate without service? ›

You can download languages onto your device. This lets you translate them without an internet connection.

Why is DeepL so much better than Google Translate? ›

Both use neural networks, but Google Translate (like most other machine translation engines) uses what are known as recurrent neural networks. By contrast, DeepL uses convolutional neural networks (CNNs), which produce better all-round results for longer, continuous sequences of words.

Is DeepL more accurate than Google? ›

DeepL is generally rated as having higher-quality translations, along with options to choose between formal and informal tones. So if you want the most accurate and natural-sounding translations, DeepL is usually the best option. Google Translate (and other services) are cheaper than DeepL.

What is the best free document translator? ›

Best Free Website Translation Tool: Six Top Options
  1. Google Translate. Google Translate is the best-known option when it comes to the best free website translation tools. ...
  2. TranslatePress. TranslatePress offers two useful translation tools: ...
  3. Bing Translator. ...
  4. Yandex Translate. ...
  5. IBM Watson Language Translator. ...
  6. ImTranslator.
13 Oct 2022

Is Google Translate a free button? ›

Google Translate is a free multilingual machine translation service developed by Google, to translate text from one language into another.

Is Google Translate data stored? ›

You can save your Google Translate history to find the meanings of words or phrases you translate. Your saved translations sync across your devices. The Translate app syncs your history from your device to the cloud. When you're signed in, your translations automatically save to the cloud.

What is the most advanced translator? ›

DeepL Translate: The world's most accurate translator.

What is the most reliable translator app? ›

Google Translate is one of the best all-round translation apps on the market. The app can detect more than 100 languages and provide offline translations to 59 languages. With their Word Lens feature, you can translate text on signs from 37 languages.

What is the most effective translator? ›

What Are the Best Free Machine Translation Tools to Use in 2022?
  1. Google Translate. Google Translate is a free online machine translation tool that helps you translate text, documents, and websites from one language to another. ...
  2. Bing Microsoft Translator. ...
  3. DeepL. ...
  4. Reverso Translation.

How much should I pay someone to Translate a document? ›

Per-word rate is the most common measurement for pricing in the translation industry. Translation rates in 2022 range from $0.09 to $0.40 per word in the United States. They vary due to factors such as language combination, volume, turnaround, and subject matter.

Will Google Translate replace translators? ›

See Beyond The Words. Google Translate's popularity is skyrocketing, and its technical qualities are improving every day. That said, it cannot replace the human touch in a translation. It can translate fragments and simple sentences, but it is unable to see beyond mere words.

Is Apple Translate better than Google Translate? ›

As of the moment, Apple's voice-based translation feature isn't as accurate as the other two. It also does not offer regional language support. Google Translator, on the other hand, is the best of the bunch. The voice recognition is impressively accurate and the translation speed is also fast.

How do you change the language of a document in Google Docs? ›

When in Docs, Sheets, or Slides, select the Menu button in the top left corner. Select Settings. A menu will appear. Select the language name that is in blue text under Language.

How do I translate a document into another language? ›

Translate a whole file
  1. On the Review tab, in the Language group, click Translate > Choose Translation Language.
  2. Under Choose document translation languages click the Translate from and Translate to languages that you want, and then click OK.

Can Google sheets automatically translate? ›

Google Sheets is a convenient platform with a plethora of built-in functions. One of those functions gives you the ability to translate the content of your spreadsheet cells into another language. You can translate any word in Google Sheets, detect languages, and create vocabulary lists.

Can I translate an entire PDF document? ›

Google Translate PDF Files for Free

Click “Choose File” and then the blue “Translate” button. Let Google work its magic. You'll get a pop-up with the PDF file translated.

How do you use Google Translate? ›

Turn Tap to Translate on or off
  1. On your Android phone or tablet, open the Translate app .
  2. At the top right, tap Menu Settings .
  3. Tap Tap to Translate. Enable. For Android 10 and up: Tap Paste . For Pixel 6 and up: To get quick translations, you can turn on Show floating icon.

Can I change language in Google Drive? ›

You can change the language of your Google Drive in you Settings. to access Settings, click on the Settings Gear and choose "Settings". Then, select a language from the drop-down menu and click "Save". Click on the settings gear to access your settings.

How do I use Google translate in Google Sheets? ›

To get started simply enter a word in one language in a cell, and then use the formula =GOOGLETRANSLATE(cell with text, “source language”, “target language”) in another cell to translate it. You can even drag the fill handle at the bottom of the formula cell down to apply this formula to more than one cell.

Can Google Translate scanned documents? ›

Things You Should Know. The Google Translate mobile can scan printed words and translate them into other languages.

What is the best program to translate a document? ›

5 best machine translation software options in the market
  1. Google Translate. Google Translate needs no introduction, being probably the most well-known machine translation software out there. ...
  2. DeepL Translator. ...
  3. Bing Microsoft Translator. ...
  4. SYSTRAN Translate. ...
  5. Amazon Translate.
12 Jan 2022

Can I translate my own documents? ›

Legally speaking, you are technically able to translate official documents yourself. However, this translation will not be accepted or recognised in a court of law or for other sensitive matters.

How do I make Google Translate work automatically? ›

Request translation or turn translation off
  1. On your computer, open Chrome.
  2. At the top right, click More. Settings.
  3. At the bottom, click Advanced.
  4. Click Languages. Language.
  5. Turn Offer to translate pages that aren't in a language you read on or off.

Is Google Translate automatic? ›

Google Translate is an affordable automatic translation tool that is easy to install.

Is there an app for PDF translation? ›

For those who need to translate PDFs often, perhaps it's worth installing the File Translator: PDF Translator mobile app. The app is free to use, but is available on Android only. To translate PDFs on your Android device using this app, open it and select File Translator.

Can Google Translate a scanned PDF? ›

Steps to translate scanned PDF:

Open the Google Chrome browser and select Google Drive. Choose any pdf files from the drive or devices. Here we select a PDF file from our browser with Google docs. Open the Tools option and select translate documents.

What is the best PDF Translator? ›

DocTranslator performs top notch translation service for any types of PDF file. And we believe it is the #1 option that is available today for any size of file. There is no hard limits on the file size, and it offers a free tier for small documents up to 1,000 words.

Videos

1. Google Translation API and Python Part 1 - Service Account, Install Library, Translate Text
(Jie Jenn)
2. Google Cloud Translate Xtension
(Dan Burke)
3. How to Use Google Cloud Translate API Key in Trados Studio CAT Tool
(Devin Gilbert)
4. Dynamic Translation | Integrating with Google Cloud Translator
(ServiceNow Support)
5. Google Cloud Translate API with VB.Net | Google Cloud Translate API | Google Cloud
(Ehasanul Hoque)
6. Google Cloud Translate API with NodeJS | Detect Language and Translate Text to other Language
(Raj Kapadia)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated: 01/01/2023

Views: 5556

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.