Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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

This method does not require a project.

In most cases, the use of MT Hive should be preferred. MT Hive integrates with the online user interface where translated files can be downloaded and sent into post editing.


URL

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

PARAMETERS

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.

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: The first matching configuration is chosen (based on file extension, name and content). Otherwise:
  3. The first matching configuration from all your configurations is chosen. See online at Settings > File 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.






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

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)

int[]?, Optional
mt

Optional. Default is true if not specified.

Set to true to disable use of MT (e.g. if enabled in the word count profile).

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.

Avoid use of false with binary files such as Microsoft Word, Excel, 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

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?, Optional


RESULTS

The operation may take more or less time depending on the amount of data to export. Therefore it is implemented as an asynchronous operation.

The API method returns an Asynchronous operation result:

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


If the operation is not completed (status = Finished), you need to poll every few seconds until completion with requestid. When finished you obtain a token to download the JSON file:

{
    "trm": {
        "requestid": 32230,
        "isbatch": false,
        "status": "Finished",
        "statusText": "Finished!"
    },
    "result": { "items": [] },
    "custom": {
        "filetoken": "1104cf62b1934e0f9ae40c43c4af1ae2",
        "segments": 4,
        "texts": 9
    }
}


Get the file: You need to use the call media/get/{token} with token is the custom/filetoken property in the previous result.


JSON FILE FORMAT

The method returns a file. It contains a JSON object with these properties:

typeFlex export descriptor. Disregard.string
versionFlex export version. Disregard.string
majorMajor version of content. Null if no versioning used.string?
minorMinor version of content. Null if no versioning used.string?
didFlex document ID.int
dsidFlex document resource ID. Can be used with other API methods that require this ID.int
cfsConfigIf includeCustomFields is true: List of all custom fields with their "id" and their title "t".object[]?
lblsConfigIf includeLabels is true: List of all custom fields with their "id" and their title "t".object[]?
chminMinimum character length for translations. Only included in JSON if a minimum is set.int?
chmaxMaximum character length for translations. Only included in JSON if a maximum is set.int?
segmentsArray of segments. See below.object[]


Each element in segments has these properties:

keySegment keystring
formatThe content format such as "plain" or "html_1".string
dtThe last date of change of any property of the segment (texts, status, ...)datetime
bsidSequential number assigned for display in the translation editor. This number may change with push requests.int
cfsSegment level custom fields (null if there are none). Each array element has properties id (custom field ID) and v (custom field value)object[]?
texts

A dictionary of texts. The key is the locale and the value a text object, see below.

"texts": { "en": {...}, "fr": {...} }


object[]


Each element in texts has these properties:

vThe text.string
st

The status in Wordbee Translator. 0 = Neutral (gray color), 1 = OK (green color), 2 = Problem (red color).

IMPORTANT: This is an important information. We strongly recommend to not update your systems with any texts that are in red status. Red status means that the translation team either did not yet work on the text or they found an issue. You should only consider texts in 0 or 1 status, depending on how the translation team is organized. Some teams may instruct translators to explicitly set translation status to "green" in which case you may only want to read those.

int
bkThe bookmark in Wordbee Translator. 0 = none, 1 = blue, 2 = redint
edLast editor. See Last Editor (Enumeration)int
dtDate of modification of text.datetime
cfsCustom fields (null if there are none). Each array element has properties id (custom field ID) and v (custom field value)object[]?
lblsLabels (null if there are none). Each array element has properties id (label ID) and v (selected label value)object[]?
cms

Comments attached to text. An array of objects with these properties:

  • v: Comment text
  • dt: Date of comment
  • uid: User ID who created comment. Find users with these method: persons/list
  • cat: A numeric category of the comment
object[]?
vc

DEPRECATED - See the "copySourceToTarget" which gives you control if empty translations are replaced or not by the source text.

Used with target languages only. Indicates if the v content is a copy of the original text:

If true then v contains the source text value because

  • the translation is empty (no text filled in from the editor)  and
  • the translation status "st" is other than 1 (OK).

In all other cases the property vc is not output.

{
   "v": "<p>Hello world</p>",
   "vc": true,
   "st": 2,
   "bk": 0,
   "ed": 0,
   "dt": "2019-10-03T15:11:02.4421331Z"
}


EXAMPLES

Basic results without custom fields, labels and comments:

{
	"type": "Wordbee Flex File Export",
	"version": "1.0",
	"dsid": 3833,
	"did": 9371,
	"major": null,
	"minor": null,
	"segments": [{
		"key": "1001",
		"dt": "2019-05-22T07:03:50.3871180Z",
		"format": "plain",
		"bsid": 2,
		"texts": {
			"en": {
				"v": "Hello world",
				"st": 0,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-20T21:43:37.562205Z"
			},
			"de": {
				"v": "Guten Tag",
				"st": 0,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-20T21:43:37.562205Z"
			}
		}
	},
	{
		"key": "1000",
		"dt": "2019-05-22T07:03:50.3871180Z",
		"format": "plain",
		"bsid": 1,
		"texts": {
			"en": {
				"v": "<p>Hello dear world</p>",
				"st": 0,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-20T21:43:37.5542057Z"
			},
			"de": {
				"v": "",
				"st": 2,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-16T12:23:37.8150027Z"
			}
		}
	}]
}


Basic results with custom fields, labels and comments:

"segments": [{
		"key": "1000",
		"dt": "2019-05-22T07:03:50.3871180Z",
		"format": "plain",
		"bsid": 1,
		"cfs": [{
			"id": 5,
			"v": "kklklklkl"
		}],
		"texts": {
			"en": {
				"v": "Hello world",
				"st": 0,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-20T21:43:37.562205Z",
				"cfs": [{
					"id": 1,
					"v": "My custom value"
				}],
				"lbls": [{
					"id": 4043,
					"v": 20
				}]
			},
			"de": {
				"v": "",
				"st": 0,
				"bk": 0,
				"ed": 0,
				"dt": "2019-05-20T21:43:37.562205Z",
				"cfs": [],
				"lbls": [],
				"cms": [],
				"cms": [{
					"v": "I have a problem with this translation. Please help.",
					"cat": 0,
					"dt": "2019-05-20T21:42:51.8853791Z",
					"uid": 278
				}]
			}
		}
	},
    ...






  • No labels