lilt-node

Lilt API Binding for Javascript

View the Project on GitHub lilt/lilt-node

LiltNode.TranslateApi

All URIs are relative to https://lilt.com/2

Method HTTP request Description
batchTranslateFile POST /translate/file Translate a File
downloadFile GET /translate/files Download translated file
monitorFileTranslation GET /translate/file Monitor file translation
registerSegment GET /translate/register Register a segment
translateSegment GET /translate Translate a segment
translateSegmentPost POST /translate Translate a segment

batchTranslateFile

TranslationInfo batchTranslateFile(fileId, memoryId, opts)

Translate a File

Start machine translation of one or more Files that have previously been uploaded. The response will include an `id` parameter that can be used to monitor and download the translations in subsequent calls. Example CURL: ``` curl –X –request POST 'https://lilt.com/2/translate/file?key=API_KEY&fileId=583&memoryId=2495&configId=123&withTM=true' ```

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let fileId = "fileId_example"; // String | List of File ids to be translated, comma separated.
let memoryId = "memoryId_example"; // String | Id of Memory to use in translation.
let opts = {
  'configId': 3.4, // Number | An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file.
  'withTM': true // Boolean | An optional boolean parameter to toggle the use of Translation Memory in the translation of the file.
};
apiInstance.batchTranslateFile(fileId, memoryId, opts).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
fileId String List of File ids to be translated, comma separated.  
memoryId String Id of Memory to use in translation.  
configId Number An optional pararameter to specify an import configuration to be applied when extracting translatable content from this file. [optional]
withTM Boolean An optional boolean parameter to toggle the use of Translation Memory in the translation of the file. [optional]

Return type

TranslationInfo

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

downloadFile

Blob downloadFile(id)

Download translated file

Download a translated File. Example CURL: ``` curl –X –request GET 'https://lilt.com/2/translate/files?key=API_KEY&id=1' ```

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let id = "id_example"; // String | A translation id.
apiInstance.downloadFile(id).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
id String A translation id.  

Return type

Blob

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

monitorFileTranslation

TranslationInfo monitorFileTranslation(opts)

Monitor file translation

Get information about the one or more Files that are being translated with machine translation. Query filters are optional but at least one must be provided. Example CURL: ``` curl –X –request GET 'https://lilt.com/2/translate/file?key=API_KEY&translationIds=1,2&fromTime=1607966744&toTime=1707966744&status=InProgress' ```

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let opts = {
  'translationIds': "translationIds_example", // String | List of translation ids, comma separated
  'status': "status_example", // String | One of the translation statuses - `InProgress`, `Completed`, `Failed`, `ReadyForDownload`
  'fromTime': 3.4, // Number | Results after this time (inclusive) will be returned, specified as seconds since the Unix epoch.
  'toTime': 3.4 // Number | Results before this time (exclusive) will be returned, specified as seconds since the Unix epoch.
};
apiInstance.monitorFileTranslation(opts).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
translationIds String List of translation ids, comma separated [optional]
status String One of the translation statuses - `InProgress`, `Completed`, `Failed`, `ReadyForDownload` [optional]
fromTime Number Results after this time (inclusive) will be returned, specified as seconds since the Unix epoch. [optional]
toTime Number Results before this time (exclusive) will be returned, specified as seconds since the Unix epoch. [optional]

Return type

TranslationInfo

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

registerSegment

TranslateRegisterResponse registerSegment(source, srclang, trglang)

Register a segment

Register a source string for interactive translation. The `source_hash` value that is returned by this request is required by the `prefix` parameter for the translation endpoint. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys.

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let source = "source_example"; // String | A source string to be registered.
let srclang = "srclang_example"; // String | An ISO 639-1 language code.
let trglang = "trglang_example"; // String | An ISO 639-1 language code.
apiInstance.registerSegment(source, srclang, trglang).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
source String A source string to be registered.  
srclang String An ISO 639-1 language code.  
trglang String An ISO 639-1 language code.  

Return type

TranslateRegisterResponse

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

translateSegment

TranslationList translateSegment(memoryId, opts)

Translate a segment

Translate a source string. Setting the `rich` parameter to `true` will change the response format to include additional information about each translation including a model score, word alignments, and formatting information. The rich format can be seen in the example response on this page. By default, this endpoint also returns translation memory (TM) fuzzy matches, along with associated scores. Fuzzy matches always appear ahead of machine translation output in the response. The `source` parameter may be supplied in the query or in the request body. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys.

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let memoryId = 56; // Number | A unique Memory identifier.
let opts = {
  'source': "source_example", // String | The source text to be translated.
  'sourceHash': 56, // Number | A source hash code.
  'prefix': "prefix_example", // String | A target prefix.
  'n': 1, // Number | Return top n translations (deprecated).
  'rich': false, // Boolean | Returns rich translation information (e.g., with word alignments).
  'tmMatches': true, // Boolean | Include translation memory fuzzy matches.
  'projectTags': false, // Boolean | Project tags. Projects tags in source to target if set to true.
  'body': new LiltNode.TranslateSegmentBody() // TranslateSegmentBody | 
};
apiInstance.translateSegment(memoryId, opts).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
memoryId Number A unique Memory identifier.  
source String The source text to be translated. [optional]
sourceHash Number A source hash code. [optional]
prefix String A target prefix. [optional]
n Number Return top n translations (deprecated). [optional] [default to 1]
rich Boolean Returns rich translation information (e.g., with word alignments). [optional] [default to false]
tmMatches Boolean Include translation memory fuzzy matches. [optional] [default to true]
projectTags Boolean Project tags. Projects tags in source to target if set to true. [optional] [default to false]
body TranslateSegmentBody   [optional]

Return type

TranslationList

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers

translateSegmentPost

TranslationList translateSegmentPost(opts)

Translate a segment

Translate a source string. Setting the `rich` parameter to `true` will change the response format to include additional information about each translation including a model score, word alignments, and formatting information. The rich format can be seen in the example response on this page. By default, this endpoint also returns translation memory (TM) fuzzy matches, along with associated scores. Fuzzy matches always appear ahead of machine translation output in the response. The maximum source length is 5,000 characters. Usage charges apply to this endpoint for production REST API keys.

Example

import LiltNode from 'lilt-node';
let defaultClient = LiltNode.ApiClient.instance;
// Configure API key authorization: ApiKeyAuth
let ApiKeyAuth = defaultClient.authentications['ApiKeyAuth'];
ApiKeyAuth.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//ApiKeyAuth.apiKeyPrefix = 'Token';
// Configure HTTP basic authorization: BasicAuth
let BasicAuth = defaultClient.authentications['BasicAuth'];
BasicAuth.username = 'YOUR USERNAME';
BasicAuth.password = 'YOUR PASSWORD';

let apiInstance = new LiltNode.TranslateApi();
let opts = {
  'body': new LiltNode.TranslateSegmentBody1() // TranslateSegmentBody1 | 
};
apiInstance.translateSegmentPost(opts).then((data) => {
  console.log('API called successfully. Returned data: ' + data);
}, (error) => {
  console.error(error);
});

Parameters

Name Type Description Notes
body TranslateSegmentBody1   [optional]

Return type

TranslationList

Authorization

ApiKeyAuth, BasicAuth

HTTP request headers