Using the Language IO API to translate files
Formatting requests
- You can use cURL, Postman, and python or javascript libraries, or any other procedure supported by REST APIs.
- You must authenticate every request with a
x-api-key
header.
Endpoints in this page
Note: You must add the Header value
Accept: application/octet-stream
. If you do not include the header, the rest API endpoint does not return the correct response. This is a requirement for the AWS API Gateway.Translate/file
Translates a piece of content to the specified target language.
POST https://agw.golinguist.com/linguistnow/resources/v1/translate/file | |||
Request Parameters | |||
file | file | yes | Run File attachments for translation. See Using the File parameter below to see the valid values. |
sourceLanguage | text | yes | Language that you translate from (see the list of supported language codes) |
targetLanguage | text | yes | Language that you translate to (see the list of supported language codes) |
Request Example (form-data) | |||
Here is what the form-data for a file translation request looks like in Postman: |
Requesting a translation
The sourceLanguage
parameter is optional (see below). The targetLanguage
parameter is mandatory. The maximum file size allowed is 6Mb.
The file translation feature supports the following file formats:
- image/jpg
- image/jpeg
- image/png
- image/bmp
- image/gif*
- application/msword (docx)
- application/vnd.openxmlformats-officedocument.wordprocessingml.document
- application/pdf**
- application/vnd.ms-powerpoint (pptx)
- application/vnd.openxmlformats-officedocument.presentationml.presentation
- application/vnd.ms-excel (xlsx)
- application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
* static gif only, not animated
** limited to 20 pages per document
Note: As best practice, you should always specify the
sourceLanguage
parameter. If you are unable to provide it, the source language is detected automatically based on the content of the file. This may be helpful in any number of cases for which the source language is unknown (for example, when batch processing files with different source languages, or for attachments that are received into a system that does not detect the language of the message).Uploading a file
Note: This procedure uses Postman as an example.
- In the Value column, click "Select files". Select a new file from your computer, or a file previously uploaded by you or a team member (for example, if you are translating the same file to another language).
- Set the sourceLanguage and targetLanguage as desired.
- Click Send.
Downloading a translation
When the translation is complete, the file is not immediately visible. To download it, follow these steps:
- Click the three-dot menu to the bottom-right of the request window:
- Select "Save response to file":
- Save the file to the desired folder.
Translated files have the same name as the source file, with a language code suffix. For example, if you translated "invoice.pdf" to French, the translated file is named "invoice_fr.pdf"
Note: Translated images such as JPG files may show visual artefacts next to the translated parts of the image. This is a normal occurrence caused by the automated Optical Character Recognition (OCR) process.
Comments
0 comments
Please sign in to leave a comment.