BatchTranslate

BatchTranslate

BatchTranslate class for handling batch translation.

Constructor

new BatchTranslate()

Source:
Example
```js
var BatchTranslate = require("www/js/BatchTranslate");
var batchTranslate = new BatchTranslate(trans.google, {
    ignoreTranslated: true,
});
await batchTranslate.batchTranslate();
```

Members

(static) procedures

Description:
  • Collection of the default procedures for batch translation.
    Procedures are functions that handle the translation process in the translation flow.
    A procedure is an async function that accept one parameter, the batch of translation data and returns batch translation info.

Source:

Collection of the default procedures for batch translation.
Procedures are functions that handle the translation process in the translation flow.
A procedure is an async function that accept one parameter, the batch of translation data and returns batch translation info.

Methods

(async) getTranslationBatchData(translator, options, trans) → {Promise.<Array.<Array.<TranslationInfo>>>}

Description:
  • Generates translation batch data for the given translator and options.

Source:
Parameters:
Name Type Description
translator Object

The translator engine to be used for translation.

options Object

The options for generating the translation batch data.

Properties
Name Type Attributes Default Description
onFinished function <optional>
function() {}

Callback function to be executed when the process finishes.

keyColumn number <optional>
0

The column index containing the keys to be translated.

translateOther boolean <optional>
false

Flag indicating whether to translate other columns.

ignoreTranslated boolean <optional>
false

Flag indicating whether to ignore already translated rows.

overwrite boolean <optional>
false

Flag indicating whether to overwrite existing translations.

saveOnEachBatch boolean <optional>
false

Flag indicating whether to save after each batch.

alwaysSparateFile boolean <optional>
false

Flag indicating whether to always translate each file separately.

filterTagMode string <optional>

Mode for filtering tags ('blacklist' or 'whitelist').

filterTag Array.<string> <optional>

Array of tags to filter rows.

targetColumn number <optional>
options.keyColumn+1

The column index where translations will be placed.

maxRequestLength number <optional>
5000

Maximum length of the request to the translator engine.

files Array.<string> <optional>

Array of files to be processed. If not provided, defaults to checked or all files.

translatiorOptions object <optional>

Additional options for the translator engine.

trans Object

The current translation instance.

Throws:

Throws an error if the translator engine is invalid.

Type
Error
Returns:

A promise that resolves to a two-dimensional array containing the translation batch data.

Type
Promise.<Array.<Array.<TranslationInfo>>>

runProcedure(procedureName, batch) → {Promise.<Array.<TranslationInfo>>}

Description:
  • Run the procedure for the given batch.

Source:
Parameters:
Name Type Description
procedureName string

The name of the procedure.

batch Array.<TranslationInfo>

The batch of translation data.

Throws:

Throws an error if the procedure is not found.

Type
Error
Returns:

A promise that resolves to the translated batch.

Type
Promise.<Array.<TranslationInfo>>

translate(batch)

Description:
  • Translate the given batch of translation data.

Source:
Parameters:
Name Type Description
batch Array.<TranslationInfo>

(static) defineProcedure(procedureName, procedure)

Description:
  • Define a procedure for batch translation.

Source:
Parameters:
Name Type Description
procedureName string

The name of the procedure.

procedure function

The procedure function.

(static) getActorGlossaryData(actorName, options) → {Object}

Description:
  • Get the actor glossary data.

Source:
Parameters:
Name Type Description
actorName string

The actor name to get the glossary data.

options Object

The options for getting the actor glossary data.

Returns:

The actor glossary data.

Type
Object