Skip to main content

Synchronize file

Use to upload a file and synchronize contents with a Flex container. The synchronization is two-way:

  • First, changes from the file can be optionally be pushed into the Flex container.

  • Second, the file contents is updated with the latest translations from the Flex container.

The result is the uploaded file with updates, if any, from the Flex container.

NOTE: This method is designed for multilingual files only. Such as Excel, CSV, POT, XLIFF and others.

URL

CODE
(POST) /api/apps/wbflex/documents/{id}/contents/sync

PARAMETERS

The URL parameters are:

id

Specify either a document ID (such as 1000) or a job ID (such as c300).

string, Mandatory

The BODY must be a JSON object with these properties:

file

A JSON object with the reference to the uploaded file, the parser configuration for content extraction and more. Please see a full list of properties here: Pushing content - "files" property . The file must be uploaded using media/upload to obtain a token, see example below.

Example:

CODE
 "file": {
        "token": "{{uploadedFile}}",
        "name": "software-strings.xlsx",
        "formatId": 137,
        "stringKeyPattern": "string-{seq}"
    }

object, Mandatory

pushMode

Optional, default is SourceAndNewTranslations

This field specifies how content is synchronized from the uploaded file to the Flex container. In many scenarios you want to sync source text changes from the file to Flex and translation changes from Flex back into the file.

The options are:

  • SourceAndNewTranslations: Sync source texts as well as translations from the file. Translations are only transferred from the file to Flex, if there is no translation yet. (Recommended mode)

  • SourceOnly: Sync source text changes only. Never transfer translations from the file to Flex (only the other way round).

  • SourceAndTranslations: Copy all content from the file to Flex. Typically this would be used when uploading content the very first time to Flex.

string, Optional

isPreviewMode

Optional boolean, default is false. If true then the system simulates the update and returns all the details but it will not actually update the Flex container.

bool, Optional

createUpdatedFile

Optional boolean, default is false.

If true, then the uploaded file will be updated with new translations and meta data and made available for download. See updatedFile.token in the results.

bool, Optional

skipStatusError

Optional boolean, default is false. If true, then any texts with status in red color will not be pulled from the Flex container into the uploaded file.

bool, Optional

segmentation

Optional.

  • Null or not specified (recommended): The system applies the segmentation rules from the Flex configuration that was used when the Flex container was created. This is the default and recommended setting..

  • srx: Apply SRX-based segmentation

  • none: Do not segment.

  • htmltags: Segment at the html tags specified in segmentationParams.

Note: When working with a specific Flex document, you should stick to a specific mechanism of segmentation. It should not be changed over time since this may lead to inconsistent splits of content.

string?, Optional

segmentationParams

Optional. Required when segmentation above is set to htmltags. Enumerate html tags at which segments shall be split. Example: "br span ul li".

string?, Optional

callback

Specify a URL which will be called upon success or failure of operation. This makes polling for operation status unnecessary. See Callbacks (with asynchronous operations)

object, Optional

RESULTS

The operation may take more or less time depending on the amount of data to push. Therefore it is implemented as an asynchronous operation. The API method returns an Asynchronous operation result:

CODE
{
  "trm": {
    "requestid":32230,
    "status":"Waiting",
    "statusText":"Waiting..."
  }
}

Specify the callback in the payload if you can process those. Otherwise and until the operation is not completed (status = Finished), you need to poll every few seconds until completion with requestid. When finished you obtain the results as a JSON:

CODE
{
    "trm": { ... }
    "custom": {
        "updatedFile": {
            "token": "0b90f03b423b44dfbbea6969e9595f01",
            "segments": 12,
            "error": null
        }
        "result": { 
            "type": "Push",
            "transaction": "2a0968cc-b234-4a35-9718-9a9c9aedcc1f",
            ...
        }
    }
}

The important fields are in the custom node. It has these properties:

updatedFile.token

Null unless createUpdatedFile was set to true.

Download the updated / synchronized file with this token using media/get/{token} . This is the original file you uploaded with any updates on source text or translations pulled from the Flex container.

string?

updatedFile.segments

0 unless createUpdatedFile was set to true.

The total number of segments updated in the file.

bool

updatedFile.error

If the file could not be generated then this property will contain a brief error message.

string?

result

Full details on the content pushed from the uploaded file to the Flex container. The information is described on this page (see the Results section and the result node):

It contains information on the segments, texts and meta-data updated in the Flex container. As well as many more details.

object

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.