Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

URLMethodsParametersDescription

/editor/instanttranslateapi/filepretranslate

POST

file: multipart/form-data; the file to translate. "0" as field name is deprecated and will not be supported in one of the next transalte5 versions.

source: string; the source language to translate from. Must be valid rfc5646 code.

target: string; the target language to translate to. Must be valid rfc5646 code.

Step 1: Starts a task-import with the file and its pretranslation.

As long as the import is running, the response in step 2 for this file will say "isImporting" instead of returning the download-link. You might need to repeat step 2 until you get the link.

The translated files are available until their configured lifetime is over; then they will be removed automatically.

Response (example): {"taskId":"539"}

/editor/instanttranslateapi/filelistGET

Step 2: Get a list of all pretranslations that are currently available for the InstantTranslate-user including their downloadUrl.

Response: allPretranslatedFiles for tasks with taskId as key .

Code Block
titleResponse layout example
{
  "allPretranslatedFiles": {
    "2237": {
	  "taskId":"2237",
      "taskName": "Apache short-en-de.html",
      "sourceLang": "en",
      "targetLang": "de",
      "downloadUrl": "/editor/task/export/id/2237?format=filetranslation",
      "removeDate": "2021-03-18",
      "importProgress": []
    }
    "2464": {
 	  "taskId":"2464", 
      "taskName": "Single word-de-en.html",
      "sourceLang": "de",
      "targetLang": "en",
      "downloadUrl": "isImporting",
      "removeDate": "2021-04-08",
      "importProgress": {
        "progress": 2, // import percentage
        "workersDone": 1, // total workers done
        "workersTotal": 9, // total queued workers
        "taskGuid": "{a5945d9f-4007-4063-ac17-41da3003dab1}",
        "workerRunning": "editor_Plugins_Okapi_Worker"
      }
    }
  },
  "dateAsOf": "2021-04-06 17:36:42"
}


editor/instanttranslateapi/writetmPOST

The request parameters must be encapsulated in data parameter as json.

ex:

data={"sourceLanguage": "en","targetLanguage": "de","source": "Simple text","target": "Einfacher Text"}

An example call via CURL could look like this:

curl --location --request POST 'http://t5docker.localdev/editor/instanttranslateapi/writetm' \
--header 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--header 'Accept: application/json' \
--header 'Translate5AuthToken: {{token}}' \
--form 'data="{\"sourceLanguage\": \"en\",\"targetLanguage\": \"de\",\"source\": \"Simple text hello\",\"target\": \"Einfacher Text hallo\"}"' 

When requesting this api endpoint, for the given language combination and for all clients of a user with InstantTranslate right, a separate OpenTM2 memory will be created (if it does not exist already) and the requested content will be saved there.

To enable InstantTranslate memory to be created for the client, this config must be set to something else then the default value, which is "disabled": runtimeOptions.InstantTranslate.saveToServices

This system config can be overridden client specific in the clients overview. By default this feature is disabled.

...