Versions Compared

Key

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

Upload a file and have it word counted and pre-translated. Then get back the translated file and word count details.

Table of Contents

URL

Code Block
(POST) /api/apps/tools/translatefiles/translate

...

The method is: apps/tools/translatefiles/presets/project/{pid}

he The body must contain a JSON object with these properties:

Original file

fileToken

The token that references the original file to process.

Use media/upload to upload your file and to obtain a token.

NOTE: This method will invalidate the file token.

string, Mandatory

src

Source locale. This is the locale of the original file.

string, Mandatory

trg

Target locale. This is the locale into which to translate.

string, Mandatory

formatId

Optional ID of a specific document format configuration to use. The configuration defines how to extract text from the original file.

The system selects a configuration as follows:

  1. If formatId is specified: This configuration will be chosen. Otherwise:

  2. If formatProfileId is

specirfied
  1. specified: The first matching configuration is chosen (based on file extension, name and content). Otherwise:

  2. The first matching configuration from all your configurations is chosen. See online at Settings > File formats

To enumerate all configurations, see: Document formats

int?, Optional

formatProfileId

Optional ID of a document format profile from which to select a format configuration. Profiles are configured online at Settings > Document format profiles.

Tip: Use helper method: apps/tools/translatefiles/presets/project/{pid}

To enumerate all profiles, see: Document format profiles


int?, Optional

Translation and word count

wordcountProfileId

Optional word count profile to use. The profile defines how to leverage memories, how to pre-translate from memories, whether to use MT and more.

If not set, then the system selects the alphabetically first word count profile configured online at Settings > Word count profiles. 

Tip: Use helper method: apps/tools/translatefiles/presets/project/{pid}

To enumerate word count profiles, see Word count profiles

int?, Optional

resourceIds

Optional list of translation/project memories or term bases to use for leveraging (as well as pre-translation).

If not set, then the system will only pre-translate with MT (if a system is enabled in the word count profile)

Tip: Use helper method: apps/tools/translatefiles/presets/project/{pid} to get project memory ID and attached resource IDs for a reference project.

int[]?, Optional

disableMT

Optional. Default is false

  • false: Default. MT is enabled or disabled as per the word count profile. 

  • true: MT is disabled always, even if word count profile enabled it

bool?, Optional

copySourceToTarget

Optional. Default is true if not specified.

  • true: Default. Populate untranslated target texts with the original content

  • false: Leave untranslated target texts empty.

Warning

Avoid use of false with binary files such as Microsoft Word, Excel,

Powerpoint

PowerPoint, InDesign etc. The system will otherwise very likely fail to build valid translated files.

bool?, Optional

Results

buildTranslatedFile

Optional. Default is true if not specified.

If true then the results will contain a file reference to download the translated file.

Use false if you are only interested in the word count information.

bool?, Optional

callbackurl

collectLeveragedHits

Optional

URL which will be called upon success or failure of operation. This makes polling for results (see below) unnecessary.

URL is called as POST request with operation result included in the body, see "RESULTS" chapter below for the JSON format.

Suggestion: Include your own references in the URL, example: http://callmeback.mycompany.com?operationid=22222&mydata=abcde

string?,

. Default is false if not specified.

If true, then the results will contain a file reference to download a JSON containing all the hits that were used for pre-translation of each segment.

bool?, Optional

callbackurl, 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)

Optional


RESULTS

The API method returns an Asynchronous operation result:

...


You can poll the status or use the callback parameter. When the operation is complete, the results are in the custom property

Code Block
languagejson
{
    "trm": {
        "requestid": 32230,
        "isbatch": false,
        "status": "Finished",
        "statusText": "Finished!"
    },
    "custom": {
       [ ****** RESULTS ****** ]
    }
}


The custom property is a JSON object:

filetokenWordcount

The file token to download the word count results as a JSON document.

Usemedia/get/{token}

The details are described here: projects/{pid}/wordcounts/{did}/{trg} but contain additional details.

string

filetokenTranslation

The file token to download the translated file.

Usemedia/get/{token}

string

parameters

fileTokenLeveragedHits

The

parameters used to word count and

file token to download a JSON with all hits used for pre-translation. Usemedia/get/{token} to download the JSON.

The parameter collectLeveragedHits must be set to true for this information to be created.

See an example below this table.

string?

parameters

The parameters used to word count and translate the file.

These are those you submitted plus the default values populated. Example:

Code Block
"parameters": {
	"fileToken": "178eee3996bd4898b31da69a4fe5b206",
	"fileName": "sample.docx",
	"src": "en",
	"trg": "fr",
	"formatProfileId": 9,
	"formatId": null,
	"wordcountProfileId": 186,
	"resourceIds": [],
	"disableMT": false,
	"copySourceToTarget": true,
	"buildTranslatedFile": true
}

object

EXAMPLES

We upload a Word file, see media/upload. We get back our fileToken, see below.

Code Block
POST /api/media/upload
BODY: multipart attachment of a Word file

 We submit the request:

...

Leveraged hits

With the fileTokenLeveragedHits token you can download a JSON with a list of the hits that were used to pre-translate the segments.

Example:

Code Block
{
  "de": [
        {
      "src": "en",     "trgdocNo": "fr1",
    "fileToken": "178eee3996bd4898b31da69a4fe5b206",        "wordcountProfileIddocSid" : 186null,
    "formatProfileId": 9,        "resourcessid": [27624594,
4630, 4401 ] } 

This returns the status of the asynchronous operation. We poll for completion. We can also include the URL callback parameter in the payload to notify us.

When the operation is finished, we get:

Code Block
{     "trm   "rid": {7837,
            "requestidsim": 0100,
            "isbatched": false1,
            "statusst": "Finished"0,
            "statusTextsrc": "Finished!"en",
       },     "resulttrg": {"de",
          "items  "stxt": [] "Good morning"
     },   },
 "custom": {      {
  "filetokenWordcount": "424366598aa1472499a87a3434688ad2",         "filetokenTranslationdocNo": "d11e5b4e5c444109a8f940ec7205b53f1-2",
            "parametersdocSid": {1,
            "fileTokensid": "178eee3996bd4898b31da69a4fe5b206"27624595,
            "fileNamerid": "sample.docx"7837,
            "srcsim": "en"99,
            "trged": "fr"1,
            "formatProfileIdst": 90,
            "formatIdsrc": null"en",
            "wordcountProfileIdtrg": 186"de",
            "resourceIdsstxt": [],"How are            "disableMT": false,you doing"
        }
    "copySourceToTarget": true,             "buildTranslatedFile": true
        }
    }
}

Download translated file:

Code Block
GET /api/media/get/d11e5b4e5c444109a8f940ec7205b53f

...

Code Block
GET /api/media/get/424366598aa1472499a87a3434688ad2

...

Code Block
{
    "segments": 1,
    "words": 2,
    "chars": 11,
    "pages": null,
    "minutes": null...

The key properties of each hit are:

  • docNo: The sequential segment number (string) in the document we translate: 1, 2, 3, 3-2, 3-3, etc.

  • docSid: Always null.

  • stxt: The hit’s source text

  • sid, rid: The hit’s numeric segment ID and resource ID

  • sim: The hit similarity

  • ed, st, src, trg: The hit’s last editor, status, source and target language

EXAMPLES

We upload a Word file, see media/upload. We get back our fileToken, see below.

Code Block
POST /api/media/upload
BODY: multipart attachment of a Word file

 We submit the request:

Code Block
POST /api/apps/tools/translatefiles/translate
BODY:
{  
    "src": "en",
    "wordsExcludedtrg": 0"fr",
    "charsTranslatedfileToken": null"178eee3996bd4898b31da69a4fe5b206",
    "wordsTranslatedwordcountProfileId" : null186,
    "wdPretransIdenticalformatProfileId": 29,
    "wdPretransIdenticalCtxresources": [ 04630, 4401 ]
  "wdPretransIdenticalPrevCtx": 0,}

This returns the status of the asynchronous operation. We poll for completion. We can also include the URL callback parameter in the payload to notify us.

When the operation is finished, we get:

Code Block
{
     "wdPretransIdenticalPrevtrm": 0,{
    "wdPretransIdenticalMT": 2,
    "wdPretransFuzzyrequestid": 0,
        "wd110isbatch": 0false,
        "wd100status": 2"Finished",
    "wdMatch1": 0,     "wdMatch2statusText": 0,"Finished!"
    "wdMatch3": 0},
    "wdMatch4result": 0,{
        "wdMatch5items": 0,[]
    "tags": 0},
    "spacescustom": 1,{
    "punctuation": 1,     "nonAsianWordsfiletokenWordcount": 0"424366598aa1472499a87a3434688ad2",
    "asianCharacters": 0,     "detailsfiletokenTranslation": {"d11e5b4e5c444109a8f940ec7205b53f",
        "countsparameters": [{
            {
   "fileToken": "178eee3996bd4898b31da69a4fe5b206",
            "localefileName": "frsample.docx",
   
            "countssrc": {"en",
                   "trg": "cfr":,
[            "formatProfileId": 9,
           { "formatId": null,
            "wordcountProfileId": 186,
            "oresourceIds": 0,
               [],
            "edisableMT": 5,
            false,
               "scopySourceToTarget": 100true,
            "buildTranslatedFile": true
        }
     "r": null,
                            "cc": 11,
}
}

Download translated file:

Code Block
GET /api/media/get/d11e5b4e5c444109a8f940ec7205b53f


Download word count details:

Code Block
GET /api/media/get/424366598aa1472499a87a3434688ad2


The word count details are a JSON document (see description of properties here projects/{pid}/wordcounts/{did}/{trg} )

Code Block
{
    "segments": 1,
    "words": 2,
    "chars": 11,
     "pages": null,
    "cwminutes": 2null,
    "wordsExcluded": 0,
    "charsTranslated": null,
    "wordsTranslated": null,
    "wdPretransIdentical": 2,
    "cswdPretransIdenticalCtx": 10,
    "wdPretransIdenticalPrevCtx": 0,
    "wdPretransIdenticalPrev": 0,
    "wdPretransIdenticalMT": 2,
      }
  "wdPretransFuzzy": 0,
    "wd110": 0,
    "wd100": 2,
    "wdMatch1": 0,
    "wdMatch2": ]0,
    "wdMatch3": 0,
    "wdMatch4": 0,
    "wdMatch5": 0,
    "dttags": "2021-07-24T14:44:45.0783981Z"0,
    "spaces": 1,
    "punctuation": 1,
    "nonAsianWords": 0,
    "asianCharacters": 0,
}    "details": {
       } "counts": [
      ],      {
  "performance": {             "global_secslocale": 1"fr",
            "mt_secs": 0,    "counts": {
                    "markupfix_secsc": [
  0,             "tm_secs": 0,        {
    "tm_mode_full_secs": 0,             "tm_mode_full_cnt": 50,
            "tm_mode_mixed_secs"o": 0,
            "tm_mode_mixed_cnt": 0,                "tm_searches_ident_cnte": 05,
              "tm_searches_ident_secs": 0,             "tm_searches_full_cnts": 0,100,
                        "tm_searches_full_secs    "r": 0null,
             "tm_100_percent": 0.0              } "cc": 11,
  }
}                          "cw": 2,
                            "cs": 1
                        }
                    ],
                    "dt": "2021-07-24T14:44:45.0783981Z"
                }
            }
        ],
        "performance": {
            "global_secs": 1,
            "mt_secs": 0,
            "markupfix_secs": 0,
            "tm_secs": 0,
            "tm_mode_full_secs": 0,
            "tm_mode_full_cnt": 50,
            "tm_mode_mixed_secs": 0,
            "tm_mode_mixed_cnt": 0,
            "tm_searches_ident_cnt": 0,
            "tm_searches_ident_secs": 0,
            "tm_searches_full_cnt": 0,
            "tm_searches_full_secs": 0,
            "tm_100_percent": 0.0
        }
    }
}

TIPS & TRICKS

Machine translation

If you want to MT the files then make sure to assign a machine translation system in the word count profile specified by parameter wordcountProfileId.

For testing purposes you might opt for the “Pseudo Translation” system which translates by converting text into uppercase letters.

If you would like to find out how much content was translated by machine then download the word count results (described further up). Look for the wdPretransIdenticalMT property which shows the total words translated by machine.

XLIFF translation

XLIFF files may already contain translations. If you do not want the existing translations be replaced by machine translations then make sure to tick this option in the XLIFF configuration you are using:

...

You may also want to consider ticking below option. It extracts status and origin of the translation:

...