Translate Word or Excel Documents with REST API

Translate Word & Excel Docs with GroupDocs.Translation Cloud

Today we are looking into the translation REST API that can translate Word and Excel documents into other languages. With GroupDocs.Translation Cloud, any document can be translated from English to Chinese, French, German, Italian, Russian, or Spanish and vice versa. So here are the language pairs in which the translation can be done.

  • English to Chinese & Chinese to English
  • English to French & French to English
  • English to German & German to English
  • English to Italian & Italian to English
  • English to Russian & Russian to English
  • English to Spanish & Spanish to English

While translating, the API takes care of paragraphs, tables, headers. footers, footnotes, endnotes, and even image captions of your Word processing documents. For the Excel spreadsheets, it supports cells, charts, tables, and also the pivot tables.

How to Translate Word or Excel Document with REST API

This article will guide you to the flow to translate the Word or Excel documents using the REST API. Here are the steps to follow:

  1. Upload the document to translate
  2. Translate the document in different languages
  3. Download the translated document

Upload Document to Translate

Upload your file at the cloud storage using the dashboard or by using the Swagger UI for the API. I will show you how to upload on the Cloud using both the options.

Upload your file using Dashboard

You may directly upload your document on the Cloud using the dashboard. All you need is to create an account on the server. Just click on the Upload a File button and select your document to upload.

Upload a file from dashboard for Translation

Upload your file using Swagger UI

The other option is to use the Swagger UI to upload your document for translation from this link.

Upload a Word or Excel file for Translation

Following will be the response from the server after the successful upload.

{
  "uploaded": [
    "document.docx"
  ],
  "errors": []
}

Translate Word or Excel Documents into Different Languages with REST API

Simple cURL command will let you translate your uploaded document. Here I am translating the Word document from English to French. The file, document.docx was uploaded earlier in myFolder under MyStorage. I intend to save the translated document as translatedDoc.docx in the same folder i.e. myFolder.

curl -X POST "https://api.groupdocs.cloud/v1.0/translation/runTranslationTask" \
-H "accept: application/json" \
-H "authorization: Bearer TOKEN" \
-H "Content-Type: application/json" \
-H "x-aspose-client: Containerize.Swagger" \
-d "'[ { \"format\":\"docx\", \"pair\":\"en-fr\", \"name\":\"document.docx\", \"folder\":\"myFolder\", \"savepath\":\"myFolder\", \"savefile\":\"translatedDoc.docx\", \"storage\":\"MyStorage\" }]'"

I wanted to translate a document from English to French, so I used the pair as “en-fr”. You can use the relevant pair according to your need from the following:

PairLanguage Translation Pairs
en-zh / zh-enEnglish to Chinese or Chinese to English
en-fr / fr-enEnglish to French or French to English
en-de / de-enEnglish to German or German to English
en-it / it-enEnglish to Italian or Italian to English
en-ru / ru-enEnglish to Russian or Russian to English
en-es / es-enEnglish to Spanish or Spanish to English

I used “docx” for the document file format. You may use according to your source Word document or Excel spreadsheet from the following:

FormatDocument Type
docMicrosoft Word 97-2003 Document
docxOffice Open XML Document
docmWord Macro-Enabled Document
xlsMicrosoft Excel 95/5.0-2003 Workbook
xlsxExcel Workbook
xlsmExcel Macro-Enabled Workbook

If you want to use the Swagger UI of the API reference to translate, you may just provide the required values in translation request and execute the command.

Whether you have run the cURL command from anywhere or use Swagger UI, in either case, following will be the response from the server after successful translation. The translated file will be stored in the mentioned folder as an output.

{
    "error": "",
    "status": "ok",
    "message": "word file saved successfully"
}

Download the Translated Document

The translated document can be easily downloaded from the Cloud storage. You may use the following cURL command, Swagger UI, or use the dashboard to download the file.

Download with cURL

curl -X GET "https://api.groupdocs.cloud/v1.0/translation/storage/file/myFolder%5CtranslatedDoc.docx?storageName=MyStorage&versionId=VsBZptoyKpehpqmUCsjuoA6jVBGsXk4B" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer TOKEN" \
-H "x-aspose-client: Containerize.Swagger"

Download using Swagger UI

Swagger UI for download will provide you the download link of the translated download. You may click on the link and save the file at your desired location.

Download file from Swagger UI
Download the translated document using Swagger UI

Download using Dashboard

The dashboard lets you select the file(s) and then you can download these using the Download button.

Download Translated Document from GroupDocs Cloud Dashboard
Download using Dashboard

You can learn more about the API from the documentation or Let’s talk more @ Free Support Forum.