diff --git a/articles/LCPublicAPI/aidocs/reference/ImportTranslationMemoryBatch.md b/articles/LCPublicAPI/aidocs/reference/ImportTranslationMemoryBatch.md new file mode 100644 index 0000000..6425bc8 --- /dev/null +++ b/articles/LCPublicAPI/aidocs/reference/ImportTranslationMemoryBatch.md @@ -0,0 +1,222 @@ + +# Trados Cloud Platform API Import Translation Memory Batch + +Import Translation Memory Batch ImportTranslationMemoryBatch POST /translation-memory/{translationMemoryId}/imports/batch + +- Friendly name: Import Translation Memory Batch +- Operation ID: ImportTranslationMemoryBatch +- HTTP Method: POST +- Path: /translation-memory/{translationMemoryId}/imports/batch + +Generates asynchronous import operations for multiple language directions using one uploaded file. The optional import settings apply to all requested language directions. + +Send the multipart form parts in this order: `properties` first, `file` second. The `properties` part contains JSON text with a non-empty `languageDirections` array and optional settings at the top level, not inside an `importSettings` object. + +The response is an array of import IDs and initial statuses. Each initial status is set to `queued`; this is not a live progress check. Use [Poll Translation Memory Import](./PollTMImport.md) with each returned `id` to retrieve its current status. + +See the [TM import/export guide](../../docs/translation-memory/Translation-memory-import-export.md#importing-multiple-language-directions) for Postman setup. + +## Parameters + +- **translationMemoryId** (path, string) - required: The identifier of the Translation Memory. +- **Authorization** (header, string) - required: The bearer access token provided by Auth0. +- **X-LC-Tenant** (header, string) - required: The identifier of the account where the request is executed. + +## Request body + +- Required: yes +- Content: multipart/form-data +- Part order: `properties`, then `file` + +```yaml +type: object +required: [properties, file] +properties: + properties: + $ref: '#/components/schemas/translation-memory-batch-import-request' + file: + type: string + format: binary +``` + +Send `properties` as JSON inside a text part and `file` as a file part. Accepted file types: `tmx`, `sdltm`, `zip`, `tmx.gz`, `sdlxliff`. + +Example value for `properties`: + +```json +{ + "languageDirections": [ + { + "sourceLanguageCode": "en-US", + "targetLanguageCode": "de-DE" + }, + { + "sourceLanguageCode": "en-GB", + "targetLanguageCode": "fr-FR" + } + ], + "targetSegmentsDifferOption": "addNew", + "unknownFieldsOption": "addToTranslationMemory", + "onlyImportSegmentsWithConfirmationLevels": [ + "translated", + "approvedTranslation" + ] +} +``` + +Use the public API property names and case-sensitive enum values, not downstream names such as `confirmationLevels`, `existingTUsUpdateMode` or `newFieldsBehaviour`. `existingFieldsUpdateMode` is not supported. + +## Response + +### 200 + +OK - returned when no import has status `queued` or `inProgress`. + +- Content: application/json +- Schema: array of `translation-memory-import-response` (see model below) + +### 202 + +Accepted - the imports have been queued for processing. + +- Content: application/json +- Schema: array of `translation-memory-import-response` (see model below) + +```json +[ + { "id": "test-import-id-1", "status": "queued" }, + { "id": "test-import-id-2", "status": "queued" } +] +``` + +### 400 + +Error codes: +- `invalid`: Invalid input in the query/form parameter mentioned in the `name` field on the error response. `languageDirections` must not be empty and each entry must include `sourceLanguageCode` and `targetLanguageCode`. +- `empty`: Empty mandatory value mentioned in the `name` field on the error response. +- `multiPartOrder`: The `properties` part must be first, followed by the `file` part. + +- Content: application/json +- Schema: `error-response` (see model below) + +### 401 + +The user could not be identified. + +- Content: application/json +- Schema: `error-response` (see model below) + +### 403 + +Error codes: +- `forbidden`: Not authorized to import translation memories. + +- Content: application/json +- Schema: `error-response` (see model below) + +### 404 + +Error codes: +- `notFound`: The translation memory or named filter could not be found. + +- Content: application/json +- Schema: `error-response` (see model below) + +All documented responses include the `X-LC-TraceId` header. + +## Model: translation-memory-batch-import-request + + +```yaml +type: object +required: [languageDirections] +properties: + languageDirections: + type: array + minItems: 1 + items: + type: object + required: [sourceLanguageCode, targetLanguageCode] + properties: + sourceLanguageCode: + type: string + targetLanguageCode: + type: string + importAsPlainText: + type: boolean + deprecated: true + default: false + exportInvalidTranslationUnits: + type: boolean + default: true + triggerRecomputeStatistics: + type: boolean + deprecated: true + default: false + targetSegmentsDifferOption: + type: string + enum: [addNew, overwrite, leaveUnchanged, keepMostRecent] + default: addNew + unknownFieldsOption: + type: string + enum: [skipTranslationUnit, ignore, addToTranslationMemory, failTranslationUnitImport] + default: addToTranslationMemory + onlyImportSegmentsWithConfirmationLevels: + type: array + items: + type: string + enum: [translated, approvedTranslation, approvedSignOff, draft, rejectedTranslation, rejectedSignOff, notTranslated] + default: [translated, approvedSignOff, approvedTranslation] + filterName: + type: string +``` + +An empty `onlyImportSegmentsWithConfirmationLevels` array imposes no confirmation-level restriction. `filterName` selects a saved filter expression to apply to all language directions; available filters are returned by [Get Translation Memory](./GetTranslationMemory.md). + +## Model: translation-memory-import-response + + +```yaml +type: object +required: [id, status] +properties: + id: + type: string + status: + type: string + deprecated: true + enum: [queued, inProgress, failed, done, cancelled] +``` + +For this POST response, `status` is initially `queued`. Poll each `id` using `GET /translation-memory/imports/{importId}`; the import completes successfully when its polled status is `done`. Other terminal statuses are `failed` and `cancelled`. + +## Model: error-response + + +```yaml +type: object +properties: + message: + type: string + errorCode: + type: string + details: + type: array + items: + $ref: '#/components/schemas/error-detail-response' +``` + +## Model: error-detail-response + + +```yaml +type: object +properties: + name: + type: string + code: + type: string + value: + type: string +``` + diff --git a/articles/LCPublicAPI/aidocs/reference/Index.md b/articles/LCPublicAPI/aidocs/reference/Index.md index 8bb13ba..2ee3ac7 100644 --- a/articles/LCPublicAPI/aidocs/reference/Index.md +++ b/articles/LCPublicAPI/aidocs/reference/Index.md @@ -353,6 +353,8 @@ |--------|------|-------------|-------------|-------| | GET | `/translation-memory/{translationMemoryId}/imports` | [GetTMImportHistory](./GetTMImportHistory.md) | Gets the import history for a translation memory. It returns the history of last 7 days. | | | POST | `/translation-memory/{translationMemoryId}/imports` | [ImportTranslationMemory](./ImportTranslationMemory.md) | Generates an asynchronous import operation.

Read more about prerequisites and limitations on the [official documentation center](https://docs.rws.com/791595/741139/trados-enterprise/importing-tm-content).
Note: The order of the multipart form parameter must be implemented as such: properties first, file second.
Use the Poll Translation Memory Import endpoint to poll until the import status is `done`.
To track the progress of the import please refer to [Poll Translation Memory Import](#/operations/PollTMImport). | | +| POST | `/translation-memory/{translationMemoryId}/imports/batch` | [ImportTranslationMemoryBatch](./ImportTranslationMemoryBatch.md) | Generates asynchronous import operations for multiple language directions using one uploaded file.
Note: The order of the multipart form parameter must be implemented as such: properties first, file second.
Use the [Poll Translation Memory Import](#/operations/PollTMImport) endpoint with each returned import ID to poll until the import status is `done`. | | + | GET | `/translation-memory/imports/{importId}` | [PollTMImport](./PollTMImport.md) | Polls a Translation Memory import operation. The import is finished when the status is `done`. | | ## Translation Memory Export diff --git a/articles/LCPublicAPI/api/Public-API.v1.json b/articles/LCPublicAPI/api/Public-API.v1.json index 6426036..9b2041e 100644 --- a/articles/LCPublicAPI/api/Public-API.v1.json +++ b/articles/LCPublicAPI/api/Public-API.v1.json @@ -19257,6 +19257,172 @@ ] } }, + "/translation-memory/{translationMemoryId}/imports/batch": { + "parameters": [ + { + "schema": { + "type": "string" + }, + "name": "translationMemoryId", + "description": "The identifier of the Translation Memory.", + "in": "path", + "required": true + } + ], + "post": { + "summary": "Import Translation Memory Batch", + "operationId": "ImportTranslationMemoryBatch", + "description": "Generates asynchronous import operations for multiple language directions using one uploaded file. The import settings apply to all requested language directions.\n
\nSend the multipart form parts in this order: properties first, file second. The properties part contains JSON text with a non-empty languageDirections array and optional import settings at the top level, not inside an importSettings object.\n
\nThe response is an array of import identifiers and initial statuses. Each initial status is set to queued; use [Poll Translation Memory Import](#/operations/PollTMImport) with each returned id to retrieve its current status.", + "tags": [ + "Translation Memory Import" + ], + "parameters": [ + { + "$ref": "#/components/parameters/Authorization" + }, + { + "$ref": "#/components/parameters/X-LC-Tenant" + } + ], + "requestBody": { + "required": true, + "description": "Send properties as a JSON string in a text part, followed by the file part. For details on multipart requests please see [this article](../docs/How-to-multipart.html).", + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "required": [ + "properties", + "file" + ], + "properties": { + "properties": { + "$ref": "#/components/schemas/translation-memory-batch-import-request" + }, + "file": { + "type": "string", + "format": "binary", + "description": "The file (binary string) to import into the translation memory for the requested language directions.
Accepted file types: .tmx, .sdltm, .zip, .tmx.gz, .sdlxliff" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK - returned when no import has status queued or inProgress.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/translation-memory-import-response" + } + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + }, + "202": { + "description": "Accepted - the imports have been queued for processing.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/translation-memory-import-response" + } + }, + "examples": { + "batch-import-accepted": { + "value": [ + { + "id": "test-import-id-1", + "status": "queued" + }, + { + "id": "test-import-id-2", + "status": "queued" + } + ] + } + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + }, + "400": { + "description": "Error codes:\n* \"invalid\": Invalid input in the query/form parameter mentioned in the \"name\" field on the error response. The languageDirections array must not be empty and each entry must include sourceLanguageCode and targetLanguageCode.\n* \"empty\": Empty mandatory value mentioned in the \"name\" field on the error response.\n* \"multiPartOrder\": The multipart order in the body is not correct. The properties part must be first, followed by the file part.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/error-response" + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + }, + "401": { + "description": "The user could not be identified.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/error-response" + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + }, + "403": { + "description": "Error codes:\n* \"forbidden\": Not authorized to import translation memories.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/error-response" + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + }, + "404": { + "description": "Error codes:\n* \"notFound\": The translation memory or named filter could not be found.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/error-response" + } + } + }, + "headers": { + "X-LC-TraceId": { + "$ref": "#/components/headers/X-LC-TraceId" + } + } + } + } + } + }, "/translation-memory/imports/{importId}": { "parameters": [ { @@ -33694,6 +33860,122 @@ "targetLanguageCode" ] }, + "translation-memory-batch-import-request": { + "title": "Translation Memory Batch Import Properties", + "type": "object", + "description": "Translation Memory batch import properties sent as JSON inside a text part. Import settings are top-level properties and apply to all language directions.", + "properties": { + "languageDirections": { + "type": "array", + "description": "The language directions to import into the translation memory.", + "minItems": 1, + "items": { + "type": "object", + "properties": { + "sourceLanguageCode": { + "type": "string", + "description": "The source language code of the import.", + "example": "en-US" + }, + "targetLanguageCode": { + "type": "string", + "description": "The target language code of the import.", + "example": "de-DE" + } + }, + "required": [ + "sourceLanguageCode", + "targetLanguageCode" + ] + } + }, + "importAsPlainText": { + "type": "boolean", + "description": "(Deprecated) Import translation units as plain text without markup.", + "deprecated": true, + "default": false + }, + "exportInvalidTranslationUnits": { + "type": "boolean", + "description": "Save translation units that failed to import in a TMX file.", + "default": true + }, + "triggerRecomputeStatistics": { + "type": "boolean", + "description": "(Deprecated) Recompute fuzzy index statistics after import.", + "deprecated": true, + "default": false + }, + "targetSegmentsDifferOption": { + "type": "string", + "description": "How to handle translation units when target segments differ.", + "enum": [ + "addNew", + "overwrite", + "leaveUnchanged", + "keepMostRecent" + ], + "default": "addNew" + }, + "unknownFieldsOption": { + "type": "string", + "description": "How to handle translation units containing unknown user-defined fields.", + "enum": [ + "skipTranslationUnit", + "ignore", + "addToTranslationMemory", + "failTranslationUnitImport" + ], + "default": "addToTranslationMemory" + }, + "onlyImportSegmentsWithConfirmationLevels": { + "type": "array", + "description": "Only import segments with the listed confirmation levels. An empty array imposes no confirmation-level restriction.", + "items": { + "type": "string", + "enum": [ + "translated", + "approvedTranslation", + "approvedSignOff", + "draft", + "rejectedTranslation", + "rejectedSignOff", + "notTranslated" + ] + }, + "default": [ + "translated", + "approvedSignOff", + "approvedTranslation" + ] + }, + "filterName": { + "type": "string", + "description": "The name of a saved filter expression to apply to all language directions. Available filters are returned by [Get Translation Memory](Public-API.v1-fv.html#/operations/GetTranslationMemory)." + } + }, + "required": [ + "languageDirections" + ], + "example": { + "languageDirections": [ + { + "sourceLanguageCode": "en-US", + "targetLanguageCode": "de-DE" + }, + { + "sourceLanguageCode": "en-GB", + "targetLanguageCode": "fr-FR" + } + ], + "targetSegmentsDifferOption": "addNew", + "unknownFieldsOption": "addToTranslationMemory", + "onlyImportSegmentsWithConfirmationLevels": [ + "translated", + "approvedTranslation" + ] + } + }, "translation-memory-import-response": { "title": "Translation Memory Import Response", "type": "object", diff --git a/articles/LCPublicAPI/docs/translation-memory/Translation-memory-import-export.md b/articles/LCPublicAPI/docs/translation-memory/Translation-memory-import-export.md index 716af4b..3d2dcba 100644 --- a/articles/LCPublicAPI/docs/translation-memory/Translation-memory-import-export.md +++ b/articles/LCPublicAPI/docs/translation-memory/Translation-memory-import-export.md @@ -52,6 +52,79 @@ For more details about translation memory imports you can also check out the [Im ![Import TM](https://github.com/RWS/language-cloud-public-api-doc-resources/blob/main/PublicAPI/ImportTM.gif?raw=true) + +## Importing multiple language directions + +Use [Import Translation Memory Batch](../../api/Public-API.v1-fv.html#/operations/ImportTranslationMemoryBatch) to import one uploaded file for multiple language directions in an existing translation memory: + +```http +POST /public-api/v1/translation-memory/{translationMemoryId}/imports/batch +``` + +In Postman, choose **Body > form-data** and add these parts in this order: + +| Key | Type | Value | +|---|---|---| +| `properties` | Text | JSON containing `languageDirections` and optional shared import settings, as shown below | +| `file` | File | The file to import (`tmx`, `sdltm`, `zip`, `tmx.gz` or `sdlxliff`) | + +Let Postman generate the multipart `Content-Type` header and boundary; do not use a raw JSON request body. + +Example value for the `properties` text part: + +```json +{ + "languageDirections": [ + { + "sourceLanguageCode": "en-US", + "targetLanguageCode": "de-DE" + }, + { + "sourceLanguageCode": "en-GB", + "targetLanguageCode": "fr-FR" + } + ], + "targetSegmentsDifferOption": "addNew", + "unknownFieldsOption": "addToTranslationMemory", + "onlyImportSegmentsWithConfirmationLevels": [ + "translated", + "approvedTranslation" + ] +} +``` + +The `languageDirections` array is required and must contain at least one entry. Each entry requires `sourceLanguageCode` and `targetLanguageCode`. + +The optional settings apply to all requested language directions: + +| Property | Default | +|---|---| +| `targetSegmentsDifferOption` | `addNew` | +| `unknownFieldsOption` | `addToTranslationMemory` | +| `onlyImportSegmentsWithConfirmationLevels` | `["translated", "approvedSignOff", "approvedTranslation"]` | +| `exportInvalidTranslationUnits` | `true` | +| `filterName` | No filter | + +Use the public API property names and case-sensitive values shown above, not downstream names such as `confirmationLevels`, `existingTUsUpdateMode` or `newFieldsBehaviour`. Settings belong at the top level of `properties`, not inside an `importSettings` object. `existingFieldsUpdateMode` is not supported by this endpoint. + +An accepted request returns HTTP `202` with an array of import IDs and initial statuses: + +```json +[ + { "id": "test-import-id-1", "status": "queued" }, + { "id": "test-import-id-2", "status": "queued" } +] +``` + +The initial `queued` status is assigned when building this response; it is not a live progress check. Poll each returned `id` separately with [Poll Translation Memory Import](../../api/Public-API.v1-fv.html#/operations/PollTMImport): + +```http +GET /public-api/v1/translation-memory/imports/{importId} +``` + +The import completes successfully when its polled status is `done`. Other terminal statuses are `failed` and `cancelled`. + + ## Polling a translation memory import Some imports may take longer, depending on the size of the Translation Memory.