Cocorita
Extends:
Cocorita class
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object): Cocorita Constructor |
Member Summary
Public Members | ||
public |
Translations object |
|
public |
Normally, when a target language translation is found missing, an empty string is emitted. |
|
public |
initialize: String[] Array of target languages to be initialized if a translation is missing |
|
public |
Target language |
|
public set |
Set target language id |
|
public get |
get target language id |
Method Summary
Public Methods | ||
public |
Get translations data serialized to json or yaml format |
|
public |
Get a copy of translations data object |
|
public |
Load translations data from a database file or a translations object |
|
public |
Translate a string of source text in the target language. |
Public Constructors
Public Members
public defaultTarget: * source
Normally, when a target language translation is found missing, an empty string is emitted. If defaultTarget value is set to 'source', the source text is emitted instead.
Public Methods
public dump(format: String): String source
Get translations data serialized to json or yaml format
Params:
Name | Type | Attribute | Description |
format | String | 'json' or 'yaml' |
Throw:
public load(source: String | Object, format: String) source
Load translations data from a database file or a translations object
Throw:
public tr(source: String, replaces: Object): String source
Translate a string of source text in the target language.
If the translation is not available in the database the method return a blank string.
If the initialize option was passed to the constructor, then this method will check all the
target languages translations for the source text and will initialize them with a blank string
were are not available.
Emit:
Emitted if target translation does not exists in data base |