Document translation tutorial

Updated at:

This document describes how to translate documents using the document translation API.

Introduction

Document translation parses text from a document and uses the Machine Translation engine to translate it. The service then creates a new file that contains the translated text in the same format as the original document.

Limits

  • Supported languages: For more information, see language codes
  • Supported document types: doc, docx, xls, xlsx, csv, ppt, pptx, txt, srt, html, htm, xml, xhtml, json, xliff, tmx, dita, md, markdown, idml, and pdf.
  • File size: Up to 50 MB.
  • The file URL (FileUrl) must be publicly accessible, use a domain name instead of an IP address, and not contain spaces. Avoid using Chinese characters in the URL.
  • The callback URL (CallbackUrl) must be publicly accessible, use a domain name instead of an IP address, and not contain spaces.
  • The result file URL (TranslateFileUrl) is valid for one hour. After the document translation task is complete, download the result file within this one-hour period.

Steps

  • You can create a document translation task (CreateDocTranslateTask).

  • Call the CreateDocTranslateTask API to create a document translation task. Pass the document location in the FileUrl parameter. The FileUrl must be a publicly accessible URL. Host your document on Object Storage Service (OSS). Then, generate a signed URL to allow the Machine Translation service to read the document.

  • After the task is created, the API returns a task ID (TaskId). Use the GetDocTranslateTask API and the TaskId to query the status of the translation task.

  • When the GetDocTranslateTask API returns a task status of translated, retrieve the URL of the translated document from the TranslateFileUrl field in the response.

Task status codes

StatusStatus codeDescription
readyPreparingThe task was created and is waiting for translation.
translatingTranslatingThe translation is in progress.
translatedTranslatedThe document was translated successfully.
errorTranslation errorAn error occurred during document translation.