Trans

Trans

The core class of Translator++
Handle basic logic of Translator++ application
This class will have one instance for each window. Which is window.trans

Constructor

new Trans()

Source:

Classes

CellInfo

Members

data

Description:
  • The current active data on the grid

Source:

The current active data on the grid

grid :Handsontable

Description:
  • Instance of the Handsontable object

Source:
See:

Instance of the Handsontable object

Type:
  • Handsontable

inProject

Description:
  • Whether trans is currently handling a project or not.

Source:

Whether trans is currently handling a project or not.

keyColumn

Description:
  • Index of key column. The column to store original texts.

Source:
Default Value:
  • 0

Index of key column. The column to store original texts.

project

Description:
  • The current project

Source:

The current project

trans.gridContextMenu

Description:
  • Grid context menu object

Source:

Grid context menu object

(static) maxCols

Description:
  • Maximum column allowed in the grid

Source:

Maximum column allowed in the grid

Methods

abortTranslation()

Description:
  • Abort translation process

Source:

addFileGroup(dirname) → {Boolean}

Description:
  • Add a new filegroup

Source:
Parameters:
Name Type Description
dirname String

name of the group

Returns:

True if success

Type
Boolean

addFileItem(file, fileObj) → {Boolean}

Description:
  • Add file item into the left panel

Source:
Parameters:
Name Type Description
file String

File ID

fileObj fileObj

File Object

Returns:
Type
Boolean

addRow(file, keyString, defaultTranslation) → {Integer}

Description:
  • Add a new key into a data

Source:
Parameters:
Name Type Description
file Any

File ID or File Object or undefined

keyString String

keyString

defaultTranslation String

Default translation

Returns:

the index of the new inserted data

Type
Integer

(async) alert(text, timeoutopt)

Description:
  • Display alert

Source:
Parameters:
Name Type Attributes Default Description
text String

Text to display

timeout Number <optional>
3000

Timeout in miliseconds

appendTags(file, row, tags) → {Array.<String>}

Description:
  • Append tags into some rows

Source:
Parameters:
Name Type Description
file String

File Id

row Number

Row index

tags String | Array.<String>

tags to set

Returns:

The current tags of the preferred row

Type
Array.<String>

appendTextToReference(text) → {Boolean}

Description:
  • Append text to the common reference

Source:
Parameters:
Name Type Description
text String

Key text to append

Returns:

Return false if failed

Type
Boolean

applySaveData(saveData) → {Object}

Description:
  • Load the trans structured data into the current project

Source:
Parameters:
Name Type Description
saveData Object

Trans structured data

Returns:
  • Instance of Trans
Type
Object

applyTransTableToSelectedCell(transTable, currentSelectionopt, transDataopt, optionsopt)

Description:
  • Apply translation table into selected cell

Source:
Parameters:
Name Type Attributes Default Description
transTable Object

Translation table formatted object

currentSelection CellRange <optional>
trans.grid.getSelected()

Cell range to put translation into

transData Array.<Array.<String>> <optional>
this.data

Two dimensional array representing the grid

options Object <optional>
Properties
Name Type Attributes Default Description
indexKey Number <optional>
0

Index of the key column

(async) autoSave(options) → {String}

Description:
  • Trigger auto save procedure

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
initiator String <optional>
auto

Who call this function

onSuccess function

Called when success

Returns:
  • Path to the saved file if success
Type
String

buildContextFromParameter(parameter) → {string}

Description:
  • Build context from parameter

Source:
Parameters:
Name Type Description
parameter Object

Object paramter

Returns:

context string

Type
string

buildIndex(fileId, rebuildopt, keyColumnopt) → {Object}

Description:
  • building indexes from trans data for faster search KEY by ID
    This function will cache the result in default index's cache location which is: trans.project.files[fileId].indexID

Source:
Parameters:
Name Type Attributes Default Description
fileId String

The file ID to process

rebuild Boolean <optional>
false

Force to rebuld index if index is already exist

keyColumn Number <optional>
0

Key column of the table

Returns:

Key-value pair of the index

Type
Object

buildIndexFromData(fileData, force) → {Object}

Description:
  • Return processed fileData on success. A transmutable function.

Source:
Parameters:
Name Type Description
fileData Object

Object of the file (trans.project.files[filePath])

force Boolean

Force rebuilding the index

Returns:

fileData (mutable)

Type
Object

buildIndexes(files, lineByLine, options) → {Object}

Description:
  • Build indexes from multiple files

Source:
Since:
  • 4.7.15
Parameters:
Name Type Description
files Array.<String>

The file ID to process

lineByLine Boolean

Whether the index processed with line-by-line algorithm or no. Default row-by-row algorithm

options Object
Returns:

Key-Object of the value pair of the index

Type
Object

calculateTableHeights(dataopt) → {Promise.<number>}

Description:
  • Asynchronously calculates the height of the table based on the provided data.

Source:
Parameters:
Name Type Attributes Default Description
data Array <optional>
this.data

The data to calculate the table height from. Defaults to the data stored in the Trans instance.

Returns:
  • A Promise that resolves with the calculated table height.
Type
Promise.<number>

clearCellInfo() → {Boolean}

Description:
  • Clear the Current Cell info section

Source:
Returns:

True if success

Type
Boolean

clearEditor() → {Boolean}

Description:
  • Clear text editor. Bottom right editor.

Source:
Returns:

True if success

Type
Boolean

clearFooter()

Description:
  • Clear the status bar

Source:

clearRow(file, rows, optionsopt) → {Number}

Description:
  • Clear translations from rows

Source:
Since:
  • 4.11.30
Parameters:
Name Type Attributes Description
file Object | String

File ID or file object

rows Number | Array.<Number>

A row or array of rows.

options Object <optional>

Options

Returns:
  • Affected row[s]
Type
Number

clearSelection()

Description:
  • Clear current selection

Source:

clearTags(file, cellRange, options) → {Array.<String>}

Description:
  • Removes one or more tags from the preferred row

Source:
Parameters:
Name Type Description
file String

File Id

cellRange Number | CellRanges

Row index

options Object
Returns:

The current tags of the preferred row

Type
Array.<String>

clearTemporaryIndexes(targetopt)

Description:
  • Clear temporary index

Source:
Parameters:
Name Type Attributes Description
target function | String <optional>

Target custom index. If empty this function will remove all indexes.

closeProject()

Description:
  • Close the current project

Source:

collectContextKeyword(objopt, filesopt, optionsopt) → {Object}

Description:
  • Generates context's keywords

Source:
Parameters:
Name Type Attributes Default Description
obj Object <optional>
trans.project

Trans.project object

files Array.<String> <optional>

List of the files

options Object <optional>

Options

Returns:

Collection of the keywords

Type
Object

(async) compress(data, options) → {Promise.<string>}

Description:
  • Compress an object

Source:
Parameters:
Name Type Description
data Buffer | String | Object
options *
Returns:
  • compressed data
Type
Promise.<string>

connectData()

Description:
  • connect this.data to trans.project.files[trans.getSelectedId()].data

Source:

copyCol(from, to, projectopt, optionsopt)

Description:
  • Copy column

Source:
Parameters:
Name Type Attributes Default Description
from Number
to Number
project Object <optional>
trans.project
options Object <optional>

copyTranslationToRow(obj, targetColumnopt, options)

Description:
  • Copy imported translation into the current objects with the same id and same row index

Source:
Parameters:
Name Type Attributes Default Description
obj trans.project | trans.project.files
targetColumn Number <optional>
1

Target column

options Object
Properties
Name Type Attributes Default Description
files Array.<String>

File IDs to process

mode 'lineByLine' | 'rowByRow' <optional>
lineByLine

Translation mode

fetch 'translated' | 'untranslated' | 'both' <optional>
translated

Fetch translated only, or untranslated only, or both

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

overwrite Boolean <optional>
false

Whether to overwrite or not if the destination cell is not empty

targetColumn Number

countFilledCol(row, data) → {Number}

Description:
  • Count how many cells are translated on the selected row
    Row index are not counted

Source:
Parameters:
Name Type Description
row Number

Row index

data Array.<Array.<String>>

Two dimensional array represents the table

Returns:

The number of the translated cells

Type
Number

countTranslated(file) → {TranslationStats}

Description:
  • Count how many rows are translated

Source:
Parameters:
Name Type Description
file String | Array.<String>

The file ID(s) to process

Returns:
Type
TranslationStats

createBackup(saveFile)

Description:
  • Generate backup from given path of trans file

Source:
Parameters:
Name Type Description
saveFile String

Path to the file

createFile(filename, dirname, options) → {Object}

Description:
  • Creates a new file(new object), register it into the left panel

Source:
Parameters:
Name Type Description
filename String

Name of the file

dirname String

Directory location

options Object
Properties
Name Type Description
originalFormat String

Original format of the file

type String

File type

Returns:
Type
Object

createProject(options)

Description:
  • Initialize a new project

Source:
Parameters:
Name Type Description
options object

force
selectedFile {array}

dataPadding() → {Trans}

Description:
  • Padding data by the length of header column

Source:
Returns:
Type
Trans

deleteFile(files, options) → {Boolean}

Description:
  • Delete files

Source:
Parameters:
Name Type Description
files String | Array.<String>

Files to be deleted

options Object
Returns:

True on success

Type
Boolean

doAfterSelection(row, column, row2, column2)

Description:
  • Standard procedure executed after selecting cells

Source:
Parameters:
Name Type Description
row Number

Row from

column Number

Column from

row2 Number

Row to

column2 Number

Column to

drawFileSelector()

Description:
  • Draw the left panel

Source:
Fires:

drawFileStatus(files)

Description:
  • Draw file status

Source:
Parameters:
Name Type Description
files Array.<String>

list of file ID

drawGridTranslatorMenu()

Description:
  • Draw grid's context menu to display translator list

Source:

editNoteAtCell(cell)

Description:
  • Open note at cell

Source:
Parameters:
Name Type Description
cell Object
Properties
Name Type Description
row Number

Row ID

col Number

Column ID

evalContextsQuery() → {Array.<String>}

Description:
  • Sanitize query for contexts

Source:
Parameters:
Type Description
String | Array

Context

Returns:
Type
Array.<String>

evalTranslationProgress(fileopt, progressDataopt)

Description:
  • Evaluate translation progress

Source:
Parameters:
Name Type Attributes Default Description
file String | Array.<String> <optional>
All

List of file IDs to be evaluated

progressData Object <optional>

Progress data

export(file, options)

Description:
  • Export current project

Source:
Parameters:
Name Type Description
file String

Path to the file/folder

options Object
Properties
Name Type Description
onDone function

Triggered when done

mode String

Export mode (ex. dir)

dataPath String

location of data path (data folder). Default is cache path

transPath String

location of the trans file. Default is using autosave on cache folder

files Array.<String>

List of the file(s) to be exported

options Object
Properties
Name Type Description
filterTag Array.<String>

Filter of the tag

filterTagMode String

Mode of the filter (whitelist||blacklist)

exportTPP(file, options)

Description:
  • Export project into a TPP file

Source:
Parameters:
Name Type Description
file String

Path to the tpp file

options *
Properties
Name Type Description
onDone function

Triggered when done

fileItemExist(file, fileObj) → {Boolean}

Description:
  • Check whether the ui element of the file is exist or not

Source:
Parameters:
Name Type Description
file String

File id

fileObj Object

File object

Returns:

True if exist

Type
Boolean

fileSelectorContextMenuInit()

Description:
  • Initialize grid's context menu

Source:

fillEmptyLine(files, rows, targetCol, sourceCol, options)

Description:
  • Fill empty lines from other column

Source:
Parameters:
Name Type Description
files String | Array.<String>

File ID or list of file ID

rows Array.<Number>

Row ID or list of row ID

targetCol Number

Target column

sourceCol Number
options Object
Properties
Name Type Attributes Default Description
project Object <optional>
trans.project
keyColumn Object <optional>
0
lineFilter function <optional>
fromKeyOnly Boolean <optional>
false
filterTag Array.<String> <optional>
overwrite Boolean <optional>
false

findAndInsert(find, values, columns, options)

Description:
  • Find a key string, then insert a text into the adjacent cell

Source:
Parameters:
Name Type Description
find String

String to find.

values String

Text to put into

columns Number

Column ID to put the values into

options Object
Properties
Name Type Attributes Default Description
overwrite Boolean <optional>
false

Whether to overwrite the existing text on the destination cell or not

files Array.<String> <optional>
this.getAllFiles()

Selected files

keyColumn Boolean <optional>
0

Key column id

insensitive Boolean <optional>
false

Whether the test is using insensitive case or not

findAndInsertByContext(find, values, columns, options)

Description:
  • find key "find", put "values" to coloumn with index "columns"
    to all files inside trans.project.files

Source:
Parameters:
Name Type Description
find String

String to find.

values String

Text to put into

columns Number

Column ID to put the values into

options Object
Properties
Name Type Attributes Default Description
overwrite Boolean <optional>
false

Whether to overwrite the existing text on the destination cell or not

files Array.<String> <optional>
this.getAllFiles()

Selected files

ignoreNewLine Boolean <optional>

Whether to ignore new line characters or not

findAndInsertLine(find, values, columns, options)

Description:
  • Find a key string, then insert a text into the adjacent cell using line-by-line algorithm

Source:
Parameters:
Name Type Description
find String

String to find.

values String

Text to put into

columns Number

Column ID to put the values into

options Object
Properties
Name Type Attributes Default Description
overwrite Boolean <optional>
false

Whether to overwrite the existing text on the destination cell or not

files Array.<String> <optional>
this.getAllFiles()

Selected files

keyColumn Boolean <optional>
0

Key column id

insensitive Boolean <optional>
false

Whether the test is using insensitive case or not

newLine String <optional>
\n

New line character

stripCarriageReturn Boolean <optional>
\n

Whether to strip charriage return character (\r) or not

findAndInsertWithIndexes(find, values, columns, indexes, options)

Description:
  • Find a key string, then insert a text into the adjacent cell
    Starting from 5.1 this function will strips carriage returns from find

Source:
Since:
  • 4.7.15
Parameters:
Name Type Description
find String

String to find.

values String

Text to put into

columns Number

Column ID to put the values into

indexes Object

index object or addresses

options Object
Properties
Name Type Attributes Default Description
overwrite Boolean <optional>
false

Whether to overwrite the existing text on the destination cell or not

files Array.<String> <optional>
this.getAllFiles()

Selected files

keyColumn Boolean <optional>
0

Key column id

lineByLine Boolean <optional>
false

to set the search mode in line by line mode

findIdByIndex(index, fileId) → {Number}

Description:
  • Find the row index by text

Source:
Parameters:
Name Type Description
index String

Index to look for

fileId String

The file ID to process

Returns:

The row index of the key string

Type
Number

findPut(keyword, put, targetCOl, options) → {SearchResult}

Description:
  • Search for some keyword and put the text on target column

Source:
Parameters:
Name Type Description
keyword String

Keyword

put String

The text to put into

targetCOl Number

The index of the column to put into

options Object
Properties
Name Type Attributes Description
caseSensitive Boolean <optional>

Whether the search is in case sensitive mode or not

lineMatch Boolean <optional>

Whether the search is with the line match mode or not

isRegexp Boolean <optional>

Whether the keyword is a regexp or not

Returns:

the search result

Type
SearchResult

(async) from(source)

Source:
Parameters:
Name Type Description
source Buffer | String

the source object

generateCachePath()

Description:
  • Generating chache path

Source:

generateContextTranslationPair(obj, options) → {Object}

Description:
  • Generates context translation pair

Source:
Parameters:
Name Type Description
obj trans.project | trans.project.files

trans.project or trans.project.files format

options Object
Properties
Name Type Attributes Default Description
files Array.<String>

File IDs to process

mode 'lineByLine' | 'rowByRow' <optional>
lineByLine

Translation mode

fetch 'translated' | 'untranslated' | 'both' <optional>
translated

Fetch translated only, or untranslated only, or both

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

Returns:

translation table object {key: "translation strings"}

Type
Object

generateHeader(transopt, prefixopt) → {Object}

Description:
  • Generating header based on the maximum length of the data

Source:
Parameters:
Name Type Attributes Default Description
trans Trans <optional>
this

Trans data

prefix String <optional>
Returns:

Column header

Type
Object

generateNewDictionaryTable() → {object}

Description:
  • Generates new dictionary table

Source:
Returns:

references object (trans.project.references)

Type
object

generateSelectedTranslationTable(currentSelectionopt, fileIdopt, optionsopt) → {Object}

Description:
  • Generates a translation table for the selected cells based on the provided parameters.

Source:
Parameters:
Name Type Attributes Description
currentSelection Array <optional>

The current selection of cells. If not provided, it defaults to the selected range in the grid.

fileId string <optional>

The file ID. If not provided, it defaults to the currently selected file ID.

options Object <optional>

Additional options for generating the translation table.

Returns:
  • The generated translation table.
Type
Object

generateTranslationPair(data, translationCol) → {Object}

Description:
  • Generates translation pair

Source:
Parameters:
Name Type Description
data Array.<Array.<String>>

Two dimensional array represents the table

translationCol Number

Column index of the preferred translation

Returns:
  • Key-value pair of translation
Type
Object

generateTranslationTable(obj, options) → {Object}

Description:
  • Generates context translation table row by row mode

Source:
Parameters:
Name Type Description
obj trans.project | trans.project.files

trans.project or trans.project.files format

options Object
Properties
Name Type Attributes Default Description
files Array.<String>

File IDs to process

mode 'lineByLine' | 'rowByRow' <optional>
lineByLine

Translation mode

fetch 'translated' | 'untranslated' | 'both' <optional>
translated

Fetch translated only, or untranslated only, or both

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

caseSensitive Boolean <optional>
false

Whether case sensitive or not

Returns:

translation table object {key: "translation strings"}

Type
Object

generateTranslationTableFromResult(keywordPool, translationPool, defaultTrans) → {Object}

Description:
  • generate translation table from translation result

Source:
Parameters:
Name Type Description
keywordPool Array.<String>

["keyword1", "keyword2", ... ]

translationPool Array.<String>

["translationOfKeyword1", "translationOfKeyword2", ...]

defaultTrans Object

Default object

Returns:

{"keyword1":"translationOfKeyword1", "keyword2":"translationOfKeyword2", ...}

Type
Object

generateTranslationTableFromStrings(input, transEngine, options) → {Object}

Description:
  • generate translation pair from strings

Source:
Parameters:
Name Type Description
input String | Array.<String>

input can be string or array of string

transEngine TranslatorEngine

Translator engine

options Object
Properties
Name Type Attributes Default Description
filterLanguage String <optional>
this.getSl()
ignoreLangCheck Boolean <optional>
boolean
ignoreLangCheck Boolean <optional>
boolean
Returns:
  • include{'source text':'translation'},
    exclude{'filtered text':''}
Type
Object

generateTranslationTableLine(obj, targetColumnopt, options) → {Object}

Description:
  • Generate translation table line by line mode

Source:
Parameters:
Name Type Attributes Default Description
obj trans.project | trans.project.files
targetColumn Number <optional>
1

Target column

options Object
Properties
Name Type Attributes Default Description
files Array.<String>

File IDs to process

mode 'lineByLine' | 'rowByRow' <optional>
lineByLine

Translation mode

fetch 'translated' | 'untranslated' | 'both' <optional>
translated

Fetch translated only, or untranslated only, or both

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

overwrite Boolean <optional>
false

Whether to overwrite or not if the destination cell is not empty

ignoreTranslated Boolean <optional>
false

Whether to skip processing or not if the row already has translation

targetColumn Number
Returns:

translation table object {key: "translation strings"}

Type
Object

getActiveTranslator() → {String}

Description:
  • Get the current active translator engine's ID

Source:
Returns:

Active translator ID

Type
String

getActiveTranslatorEngine()

Description:
  • Get currently active Translator Engine

Source:

getAllCompletedFiles(objopt) → {Array.<String>}

Description:
  • Get all files with 100% progress

Source:
Parameters:
Name Type Attributes Default Description
obj * <optional>
this.project.files

list of file objects

Returns:

List of the files

Type
Array.<String>

getAllFiles(objopt, excludeReferenceopt) → {Array.<String>}

Description:
  • Get all file ids on the project

Source:
Parameters:
Name Type Attributes Default Description
obj Object <optional>
this.project.files

list of file objects

excludeReference Boolean <optional>
false

wether to exclude reference or not

Returns:
Type
Array.<String>

getAllFilesExcept(filteredIds, objopt) → {Array.<String>}

Description:
  • Get all file ids on the project, except filteredIds

Source:
Since:
  • 4.7.17
Parameters:
Name Type Attributes Default Description
filteredIds Array.<String>

list of exceptions

obj Object <optional>
this.project.files

list of file objects

Returns:
Type
Array.<String>

getAllIncompletedFiles(objopt) → {Array.<String>}

Description:
  • Get all files with less than 100% progress

Source:
Parameters:
Name Type Attributes Default Description
obj * <optional>
this.project.files

list of file objects

Returns:

List of the files

Type
Array.<String>

getAllMarkedAsCompleted(objopt) → {Array.<String>}

Description:
  • Get all files marked as completed

Source:
Since:
  • 4.4.5
Parameters:
Name Type Attributes Default Description
obj * <optional>
this.project.files

list of file objects

Returns:

List of the files

Type
Array.<String>

getAttachmentContent(id) → {undefined|String}

Description:
  • Get attachment content by ID

Source:
Since:
  • 6.3.27
Parameters:
Name Type Description
id String

ID of the attachment

Returns:
  • Attachment content
Type
undefined | String

getCellComment(row, column, fileopt) → {String}

Description:
  • Get cell comments on a coordinate

Source:
Parameters:
Name Type Attributes Description
row Number

Row index

column Number

Column index

file String <optional>

File id

Returns:
  • Comment of the selected row, column and file
Type
String

getCheckedFiles() → {Array.<String>}

Description:
  • Get list of the checked file(s) on the left pane

Source:
Returns:

Array of the checked file id

Type
Array.<String>

getCheckedObjects() → {Object}

Description:
  • Get selected objects

Source:
Returns:

Selected object

Type
Object

getConfig(key) → {*}

Description:
  • Get project configuration
    Config are system defined configuration. Should not editable by user.

Source:
Parameters:
Name Type Description
key String

The configuration key

Returns:
  • The configuration related to the Key
Type
*

getCurrentData() → {Array.<Array.<String>>}

Description:
  • Get the currently active Table

Source:
Returns:

Two dimensional array of the data

Type
Array.<Array.<String>>

getData(file) → {Array.<Array.<String>>}

Description:
  • Get data from the file object

Source:
Parameters:
Name Type Description
file Object | String | undefined

File ID or File Object or undefined

Returns:

The array representation of the table

Type
Array.<Array.<String>>

getFromIndexes(keyword, indexesopt, customFilteropt) → {String|undefined}

Description:
  • Get data from index

Source:
Parameters:
Name Type Attributes Description
keyword String

Keyword to search for

indexes Object <optional>

Key value pair of indexes

customFilter function <optional>

Function custom filter used when building the index

Returns:
Type
String | undefined

getGridContextMenu()

Description:
  • Get the context menu object of the grid

Source:

getIndexByKey(file, keyString) → {Number|undefined}

Description:
  • Get row index based on the key string

Source:
Parameters:
Name Type Description
file String | Object

File ID or File Object to be searched

keyString String

Key string to look for

Returns:
  • Row id of the keyString if exist. Undefined if not exist.
Type
Number | undefined

getIndexIds(fileopt) → {Object}

Description:
  • Get indexes of a fileId

Source:
Parameters:
Name Type Attributes Default Description
file String | Object <optional>
this.getSelectedId()

File id or file object to be indexed

Returns:

Key-Value pair of the key text and its row index

Type
Object

getLastSelectedCell() → {Array.<Number>}

Description:
  • Get the last selected Cell

Source:
Since:
  • 4.4.4
Returns:

Array of row and column
Return [0,0] if no cell is selected;

Type
Array.<Number>

getObjectById(id) → {Object}

Description:
  • Get file object by its id

Source:
Parameters:
Name Type Description
id String

The file id

Returns:

the file object. Equal to trans.project.files[id]

Type
Object

getOption(key)

Description:
  • Get project's option
    Option are user editable configuration

Source:
Parameters:
Name Type Description
key String

getParamatersByRow(row, file) → {Object|false}

Description:
  • Get parameters by row id & file id

Source:
Parameters:
Name Type Description
row Number

The row id

file String

The file id

Returns:

parameters of the selected row or false if no parameter is found

Type
Object | false

getProjectChecksum() → {String}

Description:
  • Generate checksum for the original text
    The checksume is 32bit representation of the original texts
    So the app can determine whether the game is same or not by their respective original texts

Source:
Returns:

8 Byte of the project's checksum

Type
String

getReference(string, fileopt) → {String}

Description:
  • Search a string from reference, will return blank if not found.

Source:
Parameters:
Name Type Attributes Default Description
string String

String to search for

file String <optional>
Common Reference

File to be used as reference

Returns:

Translated text, blank if no reference found.

Type
String

getRowIdByTextInsensitive(str, fileId) → {Number}

Description:
  • Get the row ID by text. Case insensitive.

Source:
Parameters:
Name Type Description
str String

text to look for

fileId String

File to look for

Returns:

Row index

Type
Number

getRowInfoText(row, fullopt, fileopt) → {String}

Description:
  • Get row info text from file object's parameters

Source:
Parameters:
Name Type Attributes Default Description
row Number

Row index

full Boolean <optional>
false

Whether to display full result or not

file String <optional>
Trans.getSelectedId()

Target file object

Returns:

row info

Type
String

getSaveData(options) → {Object|String}

Description:
  • Create a clone structure of the trans object that ready to be saved

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
type String

Type of the returned data (""||"json"||"lz")

Returns:
  • A clone of trans object
Type
Object | String

getSelectedContext(rowNumber) → {String}

Description:
  • Get selected row's context

Source:
Parameters:
Name Type Description
rowNumber Number

Row id to look for

Returns:

Context

Type
String

getSelectedId() → {String|False}

Description:
  • returns related key ID from trans.project.files
    returning false when error

Source:
Returns:

The currently seleceted ID

Type
String | False

getSelectedKeyText(rowNumber) → {String|undefined}

Description:
  • Get selected key text from row
    Usually cell 0

Source:
Parameters:
Name Type Description
rowNumber *

Row id

Returns:

key text

Type
String | undefined

getSelectedObject() → {Object|false}

Description:
  • returns related object from trans.project.files[currently selected]
    returning false when error

Source:
Returns:
Type
Object | false

getSelectedOriginalTexts(currentSelection, fileId) → {Array.<String>}

Description:
  • Select original texts from grid selection

Source:
Parameters:
Name Type Description
currentSelection Array.<CellRange> | Array.<Array.<Number>>

Current selection

fileId String

File id

Returns:

Array of string of the selected original texts

Type
Array.<String>

getSelectedOriginalTextsAsOneLine(currentSelection, fileId) → {String}

Description:
  • Get original texts from selected cells and merge them into one line

Source:
Since:
  • 4.7.16
Parameters:
Name Type Description
currentSelection *
fileId *
Returns:

Original text of the selected cell in one line

Type
String

getSelectedParameters() → {Object}

Description:
  • Get selected row's parameters

Source:
Returns:

parameters of the selected row

Type
Object

getSelectedTexts(currentSelection, fileId) → {Array.<String>}

Description:
  • Get texts from selected cells on the grid

Source:
Since:
  • 4.7.16
Parameters:
Name Type Description
currentSelection *
fileId *
Returns:

Array of texts from the selected cells

Type
Array.<String>

getSelectedTextsAsOneLine(currentSelection, fileId) → {String}

Description:
  • Get texts from selected cells and merge them into one line

Source:
Since:
  • 4.7.16
Parameters:
Name Type Description
currentSelection *
fileId *
Returns:

Text of the selected cell in one line

Type
String

getStagingDataPath(transData) → {string}

Description:
  • Retrieves the staging data path based on the provided Trans data.

Source:
Parameters:
Name Type Description
transData any

The Trans data.

Returns:
  • The staging data path.
Type
string

getStagingFile(obj) → {String}

Description:
  • Get the real path to the staging file

Source:
Since:
  • 4.6.29
Parameters:
Name Type Description
obj String | Object

String file ID or object

Returns:

Path to the file

Type
String

getStagingPath(transDataopt) → {String|undefined}

Description:
  • Get the staging path of the current project

Source:
Since:
  • 4.4.4
Parameters:
Name Type Attributes Description
transData Trans <optional>

Trans Object to identify the staging path

Returns:

A full path to the stagging directory. Return undefined when fail

Type
String | undefined

getStats(reset) → {Object}

Description:
  • Get information of the current progress

Source:
Parameters:
Name Type Description
reset Boolean

If True, will reset the stats

Returns:

Stats of the project

Type
Object

getTemplatePath() → {String}

Description:
  • Get the template path

Source:
Returns:
  • The path to the template file
Type
String

getText(row, column, fileopt) → {String}

Description:
  • Get text from the grid

Source:
Parameters:
Name Type Attributes Description
row Number

Row index

column Number

Column index

file String <optional>

File id

Returns:
  • Text of the selected row, column and file
Type
String

getTextFromLastSelected() → {String}

Description:
  • Get text from the last selected cell

Source:
Returns:

Text of the last selected cell

Type
String

getTranslationByIndex(index) → {String}

Description:
  • Get translation by index of the translation portlet (Live translator)

Source:
Parameters:
Name Type Description
index Number

Index of the portlet

Returns:

Translated text

Type
String

getTranslationByLine(row, keyColumnopt, optionsopt) → {String}

Description:
  • Retrieve the best translation in an array with Translator++'s rule
    The rightmost cell got the priority
    Used in line-by-line translation

Source:
Parameters:
Name Type Attributes Default Description
row Array.<String>

Array of text

keyColumn Number <optional>
0

Index of the key column

options Object <optional>
Properties
Name Type Attributes Default Description
includeIndex Object <optional>
lineBreak String <optional>
\n

Line break character

onBeforeLineAdd function <optional>
Returns:

The best translation

Type
String

getTranslationColFromRow(row, keyColumnopt) → {Number}

Description:
  • Retrieve the best translation in an array with Translator++'s rule
    The rightmost cell got the priority

Source:
Parameters:
Name Type Attributes Default Description
row Array.<String>

Array of text

keyColumn Number <optional>
0

Index of the key column

Returns:

Cell index of the translation

Type
Number

getTranslationData(transDataopt, optionsopt) → {TranslationData}

Description:
  • Generate Translation Data object

Source:
Parameters:
Name Type Attributes Default Description
transData Trans <optional>
trans.getSaveData()

instance of Trans object

options Object <optional>
Properties
Name Type Attributes Default Description
keyCol Object <optional>
0

Key column of the table

groupIndex Object <optional>

index added for the translation pair prefixes

groupBy String <optional>
path

Group by what key. Default is path. use "id" to group by the key instead.

options Object <optional>
filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

wordWrapByTags Object <optional>
Fires:
  • event:onGenerateTranslationData
Returns:

Translation information

Type
TranslationData

getTranslationFromRow(row, keyColumnopt) → {String}

Description:
  • Retrieve the best translation in an array with Translator++'s rule
    The rightmost cell got the priority

Source:
Parameters:
Name Type Attributes Default Description
row Array.<String>

Array of text

keyColumn Number <optional>
0

Index of the key column

Returns:
Type
String

getTranslatorEngine(id) → {TranslatorEngine}

Description:
  • Get translator engine object by its ID

Source:
Parameters:
Name Type Description
id String

The ID of translator engine

Returns:

The translator engine

Type
TranslatorEngine

goTo(row, col, fileId)

Description:
  • Go to cell. Will select the cell and scroll the viewport to the cell.

Source:
Parameters:
Name Type Description
row Number
col Number
fileId String | JQuery

goToNewKey()

Description:
  • Go to the botom most part of the grid to the new key section

Source:

goToNextUntranslated() → {Boolean}

Description:
  • Go to the next untranslated cell

Source:
Returns:

Whether the operation is successful or not

Type
Boolean

goToPreviousUntranslated() → {Boolean}

Description:
  • Go to the previous untranslated cell

Source:
Returns:

Whether the operation is successful or not

Type
Boolean

gridBodyContextMenu()

Description:
  • Initialize grid's body context menu

Source:

gridIsModified(flagopt) → {Boolean}

Description:
  • Check whether the grid is modified or not

Source:
Parameters:
Name Type Attributes Description
flag Boolean <optional>

If flag is defined, then set the flag

Returns:
Type
Boolean

hasTags(tags, row, file) → {Boolean}

Description:
  • Check whether a row has tags or not

Source:
Parameters:
Name Type Description
tags String | Array.<String>

Check whether a row has one of these tags

row Number | Array.<Number>

Row(s) to check for

file String

the file Id

Returns:

true on success

Type
Boolean

importFromFile(file, options)

Description:
  • Import from file and replace or create object

Source:
Parameters:
Name Type Description
file String | Trans

Trans file to be imported

options Object
Properties
Name Type Description
overwrite Boolean

Will overwrite if the same file object exist

all Boolean

Will merge all file object if True

targetPair Object

Target files

files Array.<String>

List of source files

mergeData Boolean

importRPGMTrans(paths, columnsopt, options)

Description:
  • Import translation from RPGMTransPatch

Source:
Parameters:
Name Type Attributes Default Description
paths String

Path to the sheet file / folder

columns Number <optional>
1

Index of the destination column to put the translation into

options Object
Properties
Name Type Attributes Default Description
sourceColumn String <optional>
auto

The source column

overwrite Boolean <optional>
false

When True will overwrite the existing value

files Array.<String>

List of targeted files

keyColumn Number <optional>
0

Key column of the current project

stripCarriageReturn Boolean

Whether to strip the carriage retrun character or not

importSheet(paths, columnsopt, options)

Description:
  • Import sheet into the current project

Source:
Parameters:
Name Type Attributes Default Description
paths String

Path to the sheet file / folder

columns Number <optional>
1

Index of the destination column to put the translation into

options Object
Properties
Name Type Attributes Default Description
sourceColumn String <optional>
auto

The source column

overwrite Boolean <optional>
false

When True will overwrite the existing value

files Array.<String>

List of targeted files

sourceKeyColumn Number <optional>
0

Column index of the translation's key

keyColumn Number <optional>
0

Key column of the current project

stripCarriageReturn Boolean

Whether to strip the carriage retrun character or not

importTpp(file, options)

Description:
  • Load TPP file

Source:
Parameters:
Name Type Description
file Trans

Path to the .tpp file

options Object
Properties
Name Type Description
onDone function

Triggered when done

importTranslation(refPath, options)

Description:
  • Import translation from other .trans file

Source:
Parameters:
Name Type Description
refPath String | Trans

path to the Trans File or an object content of transFile

options Object
Properties
Name Type Attributes Default Description
targetColumn Number <optional>
1

target column to write for

overwrite Boolean <optional>
false

Whether to overwrite the destination cell or not

files Array.<String> <optional>

imported selected file list

destination Array.<String> <optional>

destination file list

compareMode lineByLine | rowByRow | contextTrans | copyByRow <optional>
contextTrans

Copy method

init()

Description:
  • Initialization of the Trans object

Source:

initFileNav()

Description:
  • Initialize file navigator

Source:

initProject()

Description:
  • Initialize the project

Source:
To Do:
  • Implement this function

initTable(options)

Description:
  • Initialization of the grid

Source:
Parameters:
Name Type Description
options Object

insertCell(index, value)

Description:
  • Insert cell

Source:
Parameters:
Name Type Description
index Number
value String | null

invertSelection()

Description:
  • Inverts current selection

Source:

isAllSelected() → {Boolean}

Description:
  • Check whether all available files are checked

Source:
Returns:

True if all files are checked

Type
Boolean

isFileSupported(pathName) → {boolean}

Description:
  • determine wether the pathname is supported file formats

Source:
Parameters:
Name Type Description
pathName string
Returns:

True if file is supported, otherwise false.

Type
boolean

isInContext(file, row, context) → {Boolean}

Description:
  • Check whether the a row has the context or not

Source:
Parameters:
Name Type Description
file String

The file ID

row Number

The row to look for

context Array.<String>

The context to check for

Returns:
Type
Boolean

isInProject() → {Boolean}

Description:
  • Check if a project is currently opened

Source:
Since:
  • 6.1.18
Returns:
  • Returns true if trans is in a project
Type
Boolean

isKeyExist(key) → {Boolean}

Description:
  • Check whether the key text is exist on current active file

Source:
Parameters:
Name Type Description
key String

key text to find

Returns:
Type
Boolean

isKeyExistOn(key, fileId) → {Boolean}

Description:
  • Check whether the key text is exist on a file

Source:
Parameters:
Name Type Description
key String

key text to find

fileId String

File id to search for

Returns:
Type
Boolean

isLastRow(row) → {Boolean}

Description:
  • Check whether row is the last row

Source:
Parameters:
Name Type Description
row Number

Row index to be checked

Returns:

True if row is the last row

Type
Boolean

isTranslatedRow(row, data) → {Boolean}

Description:
  • Check whether the row is translated or not

Source:
Parameters:
Name Type Description
row Number

Index of the row

data Array.<Array.<String>>

Two dimensional array represents the table

Returns:

True if the row has translation

Type
Boolean

loadComments()

Description:
  • Load comments into the grid

Source:

(async) loadJSON(filePath, options)

Description:
  • open JSON & Parse it. General purpose function

Source:
Parameters:
Name Type Description
filePath String

Path to the JSON file

options Object
Properties
Name Type Description
onSuccess function

Called when success

onFailed function

Called when failed

loadJSONSync(filePath, options) → {Object}

Description:
  • Load JSON file in synchronous fashion

Source:
Parameters:
Name Type Description
filePath String

Path to the JSON file

options Object
Returns:

Loaded JSON object

Type
Object

mergeReference(transObj) → {object}

Description:
  • merge reference into files object in transObj.project

Source:
Parameters:
Name Type Description
transObj object

instance of trans object

Returns:

instance of trans object

Type
object

mergeTrans(externalTrans, targetTransopt, options) → {Object}

Description:
  • merge externalTrans into targetTrans
    by default targetTrans = current project

Source:
Parameters:
Name Type Attributes Default Description
externalTrans Object

External instance of Trans object to be exported

targetTrans Object <optional>
this

existing instance of Trans object

options Object
Properties
Name Type Description
overwrite Boolean

Will overwrite if the same file object exist

all Boolean

Will merge all file object if True

targetPair Object

Target files

files Array.<String>

List of source files

Returns:
  • merged trans
Type
Object

moveColumn(fromIndex, toIndex) → {Trans}

Description:
  • Move a column to the new index

Source:
Parameters:
Name Type Description
fromIndex Number

Source column index

toIndex Number

Destination column index

Returns:

Instance of trans

Type
Trans

normalizeHeader()

Description:
  • Normalize loaded column header
    Apply default value & unchangeable value into trans.columns
    Should be called each time trans files are loaded

Source:

onBatchTranslationDone(options)

Description:
  • Function to run when translation is completed

Source:
Parameters:
Name Type Description
options Object

The same options with trans.translateAll function

openFile(file)

Description:
  • do some action depending on the file type

Source:
Parameters:
Name Type Description
file string

path to the file

paddingTranslation(files, columns, options)

Description:
  • Copy left padding of the key texts into translations

Source:
Parameters:
Name Type Description
files String | Array.<String>

File id(s) to process

columns Number | Array.<Number>

column to process

options Object
Properties
Name Type Attributes Default Description
keyId Number <optional>
0

The index of the key column

includeInitialWhitespace Boolean
refreshGrid Boolean

Refresh the current grid after process is completed

refreshGrid(options)

Description:
  • Refresh the grid

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
rebuild Boolean

Whether or not to rebuild the grid

onDone function

Function to run when the process is done

removeAllTranslation(files, options)

Description:
  • Clear translations from selected files

Source:
Parameters:
Name Type Description
files String | Array.<String>

File id(s)

options Object
Properties
Name Type Description
refreshGrid Boolean

Refresh the current grid after process is completed

removeColumn(column, options)

Description:
  • Removes a column
    This will affect the entire files

Source:
Parameters:
Name Type Description
column Number

Column to remove

options Object
Properties
Name Type Description
refreshGrid Boolean

Refresh the current grid after process is completed

removeDuplicates() → {Array.<Array.<string>>}

Description:
  • Remove duplicate entries from current trans.data
    Should be run once on initialization

Source:
Returns:

trans.data, two dimensional array of the grid

Type
Array.<Array.<string>>

removeNoteAtSelected(selection)

Description:
  • Remove note at selected cell

Source:
Parameters:
Name Type Description
selection Array.<CellRange>

Selected cell(s)

removeRow(file, rows, options)

Description:
  • Removes row

Source:
Parameters:
Name Type Description
file String

File to be processed

rows Number | Array.<Number>

Rows to be removed

options Object
Properties
Name Type Description
permanent Boolean

will put into the temporary bucket when false

refreshGrid Boolean

Refresh the current grid after process is completed

removeRowByContext(files, contexts, options, whitelist)

Description:
  • Deletes rows by context

Source:
Parameters:
Name Type Description
files String
contexts Array.<String>
options Object
whitelist Boolean

removeTagForSelectedRow(tagName, cellRangeopt, file, options) → {Boolean}

Description:
  • Remove tags with cellRange object

Source:
Parameters:
Name Type Attributes Default Description
tagName String | Array.<String>

Tags to put into

cellRange Array.<CellRange> <optional>
trans.grid.getSelectedRange()

Cell Range object

file String

File Id

options Object
Returns:

True on success

Type
Boolean

removeTags(file, row, tags, options) → {Array.<String>}

Description:
  • Removes one or more tags from the preferred row

Source:
Parameters:
Name Type Description
file String

File Id

row Number

Row index

tags String | Array.<String>

tags to set

options Object
Returns:

The current tags of the preferred row

Type
Array.<String>

renameColumn(column, newName, options)

Description:
  • Rename a column

Source:
Parameters:
Name Type Description
column Number
newName String
options Object
Properties
Name Type Description
refreshGrid Boolean

Refresh the current grid after process is completed

replace(keyword, replacer, options) → {SearchResult}

Description:
  • Search for some keyword and replace it with a text

Source:
Parameters:
Name Type Description
keyword String

Keyword

replacer String

Replacer

options Object
Properties
Name Type Attributes Description
caseSensitive Boolean <optional>

Whether the search is in case sensitive mode or not

lineMatch Boolean <optional>

Whether the search is with the line match mode or not

isRegexp Boolean <optional>

Whether the keyword is a regexp or not

Returns:

the search result

Type
SearchResult

resetCurentCellEditor()

Description:
  • Resets current cell editor

Source:

resetIndex()

Description:
  • Resets the index of all files

Source:

resetTags(file, options) → {Array.<String>}

Description:
  • Removes all tags settings from a file

Source:
Parameters:
Name Type Description
file String

File Id

options Object
Returns:

The current tags of the preferred file, which is an empty array

Type
Array.<String>

revertToOriginal(destinationPath, options)

Description:
  • Revert the original data into a folder
    Will replace the existing file on the destination directory

Source:
Parameters:
Name Type Description
destinationPath String
options Object

rowHasMultipleContext(row, objopt) → {Boolean}

Description:
  • Check whether a row has multiple context

Source:
Since:
  • 4.10.18
Parameters:
Name Type Attributes Default Description
row Number

Row to check

obj Object <optional>
trans.getSelectedObject()

Active object

Returns:

True if the row has more than one context

Type
Boolean

rowHasTranslation(row, keyColumnopt) → {Boolean}

Description:
  • Check whether a row has translation or not

Source:
Parameters:
Name Type Attributes Default Description
row Array.<String>

Single dimensional array representing rows

keyColumn Number <optional>
0
Returns:

True if has translation

Type
Boolean

sanitize(trans) → {Trans}

Description:
  • Sanitize instance of the Trans data

Source:
Parameters:
Name Type Description
trans Trans
Returns:
Type
Trans

(async) save(targetFile, options) → {Promise.<string>}

Description:
  • Save project into .trans file

Source:
Parameters:
Name Type Description
targetFile String

Path to the file

options Object

Object of the options

Properties
Name Type Description
initiator String

Who called the function user||auto

onAfterLoading function

Callback after the process is done

onSuccess function

Callback after the file is saved successfully

onFailed function

Callback when the error is occured

Returns:
  • The path where the file was saved
Type
Promise.<string>

(async) saveAs(targetFile, options) → {Promise.<string>}

Description:
  • Save project into .trans file with the new filename
    This function will open a blocking save dialog.

Source:
Since:
  • 4.3.16
Parameters:
Name Type Description
targetFile String

Path to the file

options Object

Object of the options

Properties
Name Type Description
initiator String

Who called the function user||auto

onAfterLoading function

Callback after the process is done

onSuccess function

Callback after the file is saved successfully

onFailed function

Callback when the error is occured

Returns:
  • The path where the file was saved
Type
Promise.<string>

scrollHToCol(col)

Description:
  • Scroll horizontally to the selected column.
    The column in argument 1 will be displayed next to the frozen cols

Source:
Parameters:
Name Type Description
col *

Column index to be shown

Description:
  • Search for some keyword

Source:
Parameters:
Name Type Description
keyword String

Keyword

options Object
Properties
Name Type Attributes Description
caseSensitive Boolean <optional>

Whether the search is in case sensitive mode or not

lineMatch Boolean <optional>

Whether the search is with the line match mode or not

isRegexp Boolean <optional>

Whether the keyword is a regexp or not

Returns:

the search result

Type
SearchResult

selectAll(filteropt, append)

Description:
  • select all with matching filter

Source:
Parameters:
Name Type Attributes Default Description
filter String | Array.<String> <optional>
All

List of the selected file ID. When empty then all will be selected

append Boolean

If true, then add into the previous selection

selectCell(row, column) → {Boolean}

Description:
  • Select a cell from grid

Source:
Parameters:
Name Type Description
row Number
column Number
Returns:

True if success

Type
Boolean

selectFile($element, options) → {JQuery}

Description:
  • Select of

Source:
Parameters:
Name Type Description
$element JQuery

Selected element

options Object
Properties
Name Type Description
onDone function

When selected done

Returns:
  • Instance of jquery of the selected element
Type
JQuery

setCellInfo(row, column)

Description:
  • Set value of the Current Cell info section

Source:
Parameters:
Name Type Description
row Number
column Number

setConfig(key, value) → {Boolean}

Description:
  • Set key-value pair of configuration

Source:
Parameters:
Name Type Description
key String | Array.<String>

The key

value *

The value

Returns:
  • True if success
Type
Boolean

setMarkAsComplete(mark, filesopt) → {Boolean}

Description:
  • Mark a file as complete

Source:
Parameters:
Name Type Attributes Default Description
mark Boolean

True if complete

files Array.<String> <optional>
this.getAllFiles()

List of the file IDs

Returns:
Type
Boolean

setStatusBarContext(row)

Description:
  • Set the value of the current context into the status menu

Source:
Parameters:
Name Type Description
row Number

Selected row

setStatusBarEngine()

Description:
  • Set the engine information section of the status bar

Source:

setStatusBarNumData() → {Boolean}

Description:
  • Set the Number of row section of the status bar

Source:
Returns:

False on fail

Type
Boolean

setTagForSelectedRow(tagName, cellRangeopt, file, options) → {Boolean}

Description:
  • Set tag for each CellRange object

Source:
Parameters:
Name Type Attributes Default Description
tagName String | Array.<String>

Tags to put into

cellRange Array.<CellRange> <optional>
trans.grid.getSelectedRange()

Cell Range object

file String

File Id

options Object
Properties
Name Type Description
append Boolean

Whether to append or to override the current value with the new value

Returns:

True on success

Type
Boolean

setTags(file, row, tags, options) → {Array.<String>}

Description:
  • Set tags to the preferred row

Source:
Parameters:
Name Type Description
file String

File Id

row Number

Row index

tags String | Array.<String>

tags to set

options Object
Properties
Name Type Attributes Description
append Boolean <optional>

Whether to append or to override the tags with the current value

Returns:

The current tags of the preferred row

Type
Array.<String>

setTrayIcon(type)

Source:
Parameters:
Name Type Description
type String

Type of the icon (notice, warning, notice, translatorPlusPlus)

(async) stagingFilesRemove(files)

Description:
  • Remove one or more files from staging directory
    This function is useful for cleaning up staging files for example after removing the project's object

Source:
Since:
  • 4.4.4
Parameters:
Name Type Description
files Array.<String>

List of files to be removed

textEditorSetValue(text, triggerEventopt)

Description:
  • Get the value of the Text Editor field

Source:
Parameters:
Name Type Attributes Default Description
text String

Value of the Text Editor field

triggerEvent Boolean <optional>
false

Trigger change event

translateAll(translator, options)

Description:
  • Execute batch translation and automatically detect translation mode

Source:
Parameters:
Name Type Description
translator TranslatorEngine

Selected Translator engine object

options Object
Properties
Name Type Attributes Default Description
onFinished function <optional>

Function to run when the process completed

keyColumn Number <optional>
0

Key column index of the table

translateOther Boolean <optional>

Whether to translate unselected files or not

saveOnEachBatch Boolean <optional>

Whether to save project for each batch

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

overwrite Boolean <optional>
false

Whether to overwrite or not if the destination cell is not empty

ignoreTranslated Boolean <optional>
false

Whether to skip processing or not if the row already has translation

translateAllByLines(translator, options)

Description:
  • Execute batch translation with line-by-line mode

Source:
Parameters:
Name Type Description
translator TranslatorEngine

Selected Translator engine object

options Object
Properties
Name Type Attributes Default Description
onFinished function <optional>

Function to run when the process completed

keyColumn Number <optional>
0

Key column index of the table

translateOther Boolean <optional>

Whether to translate unselected files or not

saveOnEachBatch Boolean <optional>

Whether to save project for each batch

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

overwrite Boolean <optional>
false

Whether to overwrite or not if the destination cell is not empty

ignoreTranslated Boolean <optional>
false

Whether to skip processing or not if the row already has translation

translateAllByRows(translator, options)

Description:
  • Execute batch translation with row by row mode

Source:
Parameters:
Name Type Description
translator TranslatorEngine

Selected Translator engine object

options Object
Properties
Name Type Attributes Default Description
onFinished function <optional>

Function to run when the process completed

keyColumn Number <optional>
0

Key column index of the table

translateOther Boolean <optional>

Whether to translate unselected files or not

saveOnEachBatch Boolean <optional>

Whether to save project for each batch

filterTag Array.<String> <optional>

Tags filter

filterTagMode 'blacklist' | 'whitelist' <optional>

Filter mode

overwrite Boolean <optional>
false

Whether to overwrite or not if the destination cell is not empty

ignoreTranslated Boolean <optional>
false

Whether to skip processing or not if the row already has translation

translateByReference(input, caseInSensitiveopt, referenceNameopt) → {String}

Description:
  • Get translation from common reference. The behavior is like translation procedure.
    Will return original text if no reference found

Source:
Parameters:
Name Type Attributes Default Description
input String

String to be translated

caseInSensitive Boolean <optional>
false

Whether to perform case insensitive search or not

referenceName String <optional>
"Common Reference"

The name of the reference file object

Returns:

translated string

Type
String

translateFromArray(obj, columns, options)

Description:
  • translate from array obj

Source:
Parameters:
Name Type Description
obj *
columns Number
options Object
Properties
Name Type Attributes Default Description
sourceColumn Number | 'auto'
overwrite Boolean <optional>
false

Whether to overwrite the existing text on the destination cell or not

sourceKeyColumn Number <optional>
0

The source key column

files Array.<String> <optional>
this.getAllFiles()

Selected files

keyColumn Boolean <optional>
0

Key column id

newLine String <optional>
\n

New line character

stripCarriageReturn Boolean <optional>
\n

Whether to strip charriage return character (\r) or not

translateFromTrans(text, fileFilteropt, transDataopt) → {String|undefined}

Description:
  • Search a translation from given trans data

Source:
Since:
  • 6.1.14
Parameters:
Name Type Attributes Default Description
text String | Array.<String>

Original text to translate

fileFilter String | Array.<String> <optional>

Destination file ID to search into. If blank then the method will search all file object

transData Trans <optional>
this

Trans Data

Returns:
  • translation result
Type
String | undefined

translateSelectedRow(row, col) → {Boolean}

Description:
  • Translate selected row with translation pane. (Live translator)

Source:
Parameters:
Name Type Description
row Number
col Number
Returns:
Type
Boolean

translateSelection(currentSelectionopt, options)

Description:
  • Determines translate selection by row or by line

Source:
Parameters:
Name Type Attributes Default Description
currentSelection Array.<CellRange> <optional>
trans.grid.getSelected()

Cell range to be translated

options Object
Properties
Name Type Attributes Default Description
translatorEngine Object <optional>
this.getActiveTranslatorEngine()

Translator engine to be used

translateSelectionByLine(currentSelectionopt, options)

Description:
  • Translate selected cell with line-by-line algorighm

Source:
Deprecated:
  • - Since 5.1.0
Parameters:
Name Type Attributes Default Description
currentSelection Array.<CellRange> <optional>
trans.grid.getSelected()

Cell range to be translated

options Object
Properties
Name Type Attributes Default Description
translatorEngine Object <optional>
this.getActiveTranslatorEngine()

Translator engine to be used

translateSelectionByRow(currentSelectionopt, options)

Description:
  • Translate selected cell with row-by-row algorighm

Source:
Deprecated:
  • - Since 5.1.0
Parameters:
Name Type Attributes Default Description
currentSelection Array.<CellRange> <optional>
trans.grid.getSelected()

Cell range to be translated

options Object
Properties
Name Type Attributes Default Description
translatorEngine Object <optional>
this.getActiveTranslatorEngine()

Translator engine to be used

translateSelectionIntoDef(currentSelection)

Description:
  • Translate using all availables translator into their corresponding default column.

Source:
Parameters:
Name Type Description
currentSelection CellRange

translateStringByPair(str, translationPair, caseInSensitive) → {String}

Description:
  • Translate string by translation pair

Source:
Parameters:
Name Type Description
str String

String to translate

translationPair Object

Key value based translation pair object

caseInSensitive Boolean

Whether or not the translation is in case insensitive mode

Returns:

Translated result

Type
String

translateTextByLine(text, translationPair)

Description:
  • Translate text with line-by-line algorithm

Source:
Parameters:
Name Type Description
text String

multilined text

translationPair Object

Key pair translation object

travelContext(files, contexts, options)

Description:
  • Iterate through contexts

Source:
Parameters:
Name Type Description
files String | Array.<String>

Selected files

contexts String | Array.<String>

Context to search for

options Object
Properties
Name Type Description
onMatch function
onNotMatch function
matchAll Boolean

trimTranslation(files, columns, options)

Description:
  • remove whitespace from translation

Source:
Parameters:
Name Type Description
files String | Array.<String>

File id(s) to process

columns Number | Array.<Number>

column to process

options Object
Properties
Name Type Description
refreshGrid Boolean

Refresh the current grid after process is completed

unInitFileNav()

Description:
  • Un-initialize file navigator

Source:
Fires:

(async) uncompress(data, options) → {Promise.<string>}

Description:
  • Uncompress a string

Source:
Parameters:
Name Type Description
data Buffer | String

Compressed string

options *
Returns:
  • uncompressed string
Type
Promise.<string>

updateProject(jsonData, options) → {Trans}

Description:
  • update current trans with new jsonData

Source:
Parameters:
Name Type Description
jsonData Trans

jsonData must contains jsonData.project.files

options *
Returns:
  • An updated trans data
Type
Trans

updateStagingInfo(transDataopt)

Description:
  • Update gameInfo.json at staging location

Source:
Parameters:
Name Type Attributes Description
transData Trans | undefined <optional>

Trans data

walkToAllFile()

Description:
  • iteratively select all files and return to the last selection

Source:

wordWrapFiles(filesopt, colopt, targetColopt, optionsopt)

Description:
  • Word wrap a file object

Source:
Parameters:
Name Type Attributes Default Description
files Array.<String> <optional>
this.getAllFiles()

List of files to be processed

col Number <optional>
1

Column ID to be processed

targetCol Number <optional>
col+1

Column of the processed text will put into

options Object <optional>
Properties
Name Type Attributes Default Description
maxLength Number <optional>
41

Maximum length of the line

context Array.<String> <optional>

Context filter. Only the rows that has this context will be processed

onDone function <optional>

Triggered when the process is completed

wordWrapText(str, rowTagsopt, wordWrapByTagsopt, lineBreakopt) → {String}

Description:
  • Word wrap a text

Source:
Parameters:
Name Type Attributes Default Description
str String
rowTags Array.<String> <optional>
[]

List of tags of the current row

wordWrapByTags Array.<String> <optional>
[]

List of tags to filter

lineBreak String <optional>
"\n"

Line break character

Returns:

Word wrapped text

Type
String

Events

afterRemoveRow

Description:
  • Triggered after removing rows

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
file String

file id

rows Array.<Number>

List of rows

options Object

beforeProcessSelection

Description:
  • Triggered after grid selection

Source:
Parameters:
Name Type Description
arguments arguments

clearContextTranslationByRow

Description:
  • Trigger when user runs Clear Context Translation

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
file Object
row Object
type Object

documentModifiedStateChange

Description:
  • Triggered when grid is modified

Source:
Parameters:
Name Type Description
flag Boolean

languageChange

Description:
  • Triggered when the default translator is changed

Source:
Since:
  • 4.12.10
Parameters:
Name Type Description
sl String

Source language

tl String

Target language

onAfterSelectCell

Description:
  • Trigger event right after a cell(s) is selected

Source:
Parameters:
Name Type Description
Options Object
Properties
Name Type Description
fromRow Number
fromCol Number
toRow Number
toCol Number
isLastRow Boolean

onGenerateTranslationData

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
info Object
translationData Object

onLoadTrans

Description:
  • Trigger event after trans file is loaded

Source:

onUnloadTrans

Description:
  • Triggers after a project is closed.

Source:

projectCreated

Description:
  • Executed when a project is created

Source:
Parameters:
Name Type Description
trans Trans

Instance of the current trans data

data Object

removeAllTranslation

Description:
  • Triggered when all all translation are removed

Source:
Parameters:
Name Type Description
Options Object
Properties
Name Type Description
files Array.<String>

List of the file ids

options Object

Options

transLoaded

Description:
  • Executed each time trans file is loaded or initialized

Source:

transLoaded

Description:
  • Triggers after trans loaded

Source:
Parameters:
Name Type Description
this Trans

Instance of trans

translatorIsChanged

Description:
  • Triggered when the default translator is changed

Source:
Since:
  • 4.3.20
Parameters:
Name Type Description
oldTranslator String

The id of the old translator

newTranslator String

The id of the new Translator