Work with Import and Export XLIFF APIs
This article explains how you can import and export XLIFF files using APIs.
Overview
Import and Export XLIFF API allows you to export an XLIFF template for Engagements, Knowledge Center Bots, and Articles that are ready for translation and import the translated XLIFF file from the localization platform back to the corresponding Engagement, Knowledge Center Bot, and Article.
Import XLIFF API
This API allows you to import XLIFF content for translations of Engagements, Knowledge Center Bot, and Articles from your localization platform.
Request Method: Post
Path:
Type | Endpoint |
Engagement | v1/localization/import/engagement |
Knowledge Center Bot | v1/localization/import/kcbot |
Articles | v1/localization/import/articles |
Parameters:
Name | Type | Required | Description |
file | File | true | The XLIFF file |
Response Structure:
- 201 - Created
- 432 - XLIFF parsing error
- 433 - Engagement id not found in XLIFF file
- 434 - Target language is not part of subscription's allowed languages
- 437 - Strategy is not valid
- 438 - XLIFF version is not supported
Example:
curl --location --request POST 'https://api.aptrinsic.com/v1/localization/import' \ --header 'X-APTRINSIC-API-KEY: xxxxxxxxxx-xxxx-xxxx-xxxxxxxx' \ --header 'Content-Type: multipart/form-data; boundary=BOUNDARY' \ --form 'file=@"en_sp.xliff"'
Note: You can also upload translated files to an active engagement in a non production environment using the Import API.
Export XLIFF API
Using the export XLIFF APIs, you can now download the blank template, or the translated XLIFF files for Knowledge Center and Articles. When downloading content for a non-translated language, the file will not contain the <target> elements. To finish the translation process, add the translated content inside the <target> elements for each of the <source> elements and upload the resulting file using the Import API.
IMPORTANT: It is mandatory that the version and strategy values remain the same for files that are exported, translated, and then uploaded.
Request Method: Get
Path:
Type | Endpoint |
Engagement | v1/localization/export/engagement |
Knowledge Center Bot | v1/localization/export/kcbot |
Articles | v1/localization/export/articles |
Parameters:
Name |
Type |
Required |
Default |
Description |
---|---|---|---|---|
version | File | false | 2.0 | The XLIFF version to be exported (default 2.0) |
trgLang | string | true | Language code | Target language to be included in output XLIFF. Must be enabled in the subscription’s Localization settings. If a sample file is desired, use the default language (for instance, en-US). |
strategy | string | false | html or contextual |
|
id | string | false |
Only specific ID filter
|
If the export operation is successful, the endpoint returns a zip file containing .xlf files as a binary stream (Content-Type: application/octet-stream). If the operation fails, it returns one of the following errors.
Response Error Status Codes:
- 435 - Engagement is not found
- 436 - Engagement has no content
- 437 - Strategy is not valid
- 438 - XLIFF version is not supported
Note: You can download an uploaded XLIFF file using the Export API. This provides you with a translated file that lets you edit content easily.
IMPORTANT: This is applicable only when the values of version and strategy of import and export XLIFF files remain the same.