1.0.12 • Published 6 years ago
viva-translator v1.0.12
Translator
(license MIT) simple translator, full example - see example.js
Kind: global class
translator.init(language, path, left, right, timeout_save) ⇒ string
initialization translator, set root path for storage text translate files
Kind: instance method of Translator
Returns: string - full path name for storage text translate files
Param | Type | Description |
---|---|---|
language | string | base (main) language |
path | string | root path for text translate files, if empty - set __dirname/translate |
left | string | left border for mark non-translate substring, if empty - "{" |
right | string | right border for mark non-translate substring, if empty - "}" |
timeout_save | number | timeout (in minutes) save translate data to disk, need for save last_read_datetime, default - "60" |
translator.translate(language, text, replaces, tags) ⇒ string
translate text
Kind: instance method of Translator
Param | Type | Description |
---|---|---|
language | string | translate to this language |
text | string | text for translate |
replaces | string | Array.<string> | substitutions |
tags | string | Array.<string> | tags for phrase |
translator.translateExt(language, text, tags) ⇒ string
translate text with auto-check replaces
Kind: instance method of Translator
Param | Type | Description |
---|---|---|
language | string | translate to this language |
text | string | text for translate |
tags | string | Array.<string> | tags for phrase |
translator.translate_back(language, text) ⇒ string
find base language text by text in secondary language
Kind: instance method of Translator
Param | Type |
---|---|
language | string |
text | string |