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
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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