You can use the REST API to automatically export and import the Translation ZIP.

Create the translation ZIP file

If Scroll Versions is activated in the space you are exporting, you first have to get the version ID of the version you want to export.

You can do this by sending a GET request to:
<confluence-base-url>/rest/scroll-versions/1.0/versions/<spaceKey>

The response will look like this:

[
    {
        "id": "<versionId>",
        "name": "<versionName>",
        ...
    },
    ...
]
CODE

Then send a POST request with Content-Type: application/json to:
<confluence-base-url>/rest/scroll-versions/1.0/translation/start

The body should consist of data with following parameters:

KeyValue
languageKeyThe key of the language to export (e.g. 'en' for english).
outdatedOnly'true' if only pages with status 'outdated' should be exported, else 'false'.
provider
  • 'simple' for simple translation provider
  • 'xliff' for XLIFF translation provider
spaceKeyThe spacekey of the space you want to export.

variantId (optional - only if Variant Management is activated)

The ID of the variant you want to export, 'all' for every variant.
versionId (optional - only if Version Management is activated)The ID of the version you want to export.
oneFilePerPage (optional)false (default) or true. When using 'xliff' for provider, this parameter has to be defined in the body and set to true value

The respond looks like this:

{
    "id": "<taskId>",
    ...
}
CODE

To check the created file send the following get request:
<confluence-base-url>/rest/scroll-versions/1.0/async-tasks/<taskId>?since=<dateTime>

If the file was successfully created, the response will look like this:

{
    "id": "<taskId>",
    ...
    "result": {
        "id": "<fileId>",
        "descriptor": {
        	...
        },
        "fileName": "<fileName>"
    }
}
CODE

Download the translation ZIP File

Download the created translation ZIP file from:
<confluence-base-url>/rest/scroll-versions/1.0/translation/adapter/simple/download/<fileId>/<translationProvider>/<fileName>

(info) Both <fileId> and <fileName> can be found in the response to our previous request which checks the translation zip file.

Upload the translation ZIP File

  1. Send a post request to:
    <confluence-base-url>/rest/scroll-versions/1.0/translation/adapter/simple/upload?spaceKey=<spaceKey>&translationProvider=simple

    (info) <spaceKey> is the key of the space you want to import the file to.
  2. Add the file to the request as multipart-form-data from a file-input (see HttpClient Documentation).
    When the Translation ZIP file was uploaded successfully, the response will look like this:

    {
        "success": true,
        "result": {
            "id": "<fileId>",
            "descriptor": {
            	...
            }
        },
        ...
    }
    CODE

    (info) The <fileId> is needed to import the file.

Import the Translations ZIP File

  1. Send a post request to:
    <confluence-base-url>/rest/scroll-versions/1.0/translation/import?spaceKey=<spaceKey>&id=<fileId>&translationProvider=simple

    (info) <spaceKey> and <fileId> are the parameters from step 3.
  2. The response looks like this:

    {
        "id": "<taskId>",
        "clusterNo": -1,
        "started": false,
        "cancelled": false,
        "hasFailed": false,
        "finished": false,
        "failureMessage": null,
        "progress": 0,
        "message": "The task 'Translation.Import' is currently queued.",
        "resourceLocation": null
    }
    CODE

     (info) Note that the individual fields may be different, depending on your timing on your server's workload.

  3. To get the current status of the import, send a Get-Request to:
    <confluence-base-url>/rest/scroll-versions/1.0/async-tasks/<taskId>?since=<dateTime>
    (info) <dateTime>
    is the current time (as int).