jslingua~JsLingua

Global class which affords services for a specific language

JsLingua

Methods

static aserv(serviceID, langCode, theClass)

Add a service for a specific language
Parameters:
Name Type Description
serviceID String The services name: "Info", "Lang", etc.
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
theClass Object The class that affords the service

static gdir(langCode) → {String}

To recover the direction of writing for the given language
This can be done using the info.js instance of the target language. But, the direction is used a lot for presentation, so a centralized version is to be afforded, so we don't import the js file for each language in each webpage.
Parameters:
Name Type Description
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
Returns:
String - either "rtl" or "ltr"

static getDir(langCode) → {String}

To recover the direction of writing for the given language
This can be done using the info.js instance of the target language. But, the direction is used a lot for presentation, so a centralized version is to be afforded, so we don't import the js file for each language in each webpage.
Parameters:
Name Type Description
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
Returns:
String - either "rtl" or "ltr"

static getService(serviceID, langCode) → {Class}

Get the service class for a given language and service name.
For example: JsLingua.getService("Info", "ara") Gives a class AraInfo
Parameters:
Name Type Description
serviceID String The name of the service (the super-classe): "Info", "Lang", etc.
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
Returns:
Class - The class that affords the service

static getVersion() → {String}

Returns the version of JsLingua
Returns:
String - JsLingua version

static gserv(serviceID, langCode) → {Class}

Get the service class for a given language and service name.
For example: JsLingua.gserv("Info", "ara") Gives a class AraInfo
Parameters:
Name Type Description
serviceID String The name of the service (the super-classe): "Info", "Lang", etc.
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
Returns:
Class - The class that affords the service

static gversion() → {String}

Returns the version of JsLingua
Returns:
String - JsLingua version

static listLanguages(serviceID) → {Array.<String>}

Get the codes of available languages of a given service
Parameters:
Name Type Description
serviceID String The name of the service (the super-classe): "Info", "Lang", etc.
Returns:
Array.<String> - array of strings, with ISO639-2 codes

static llang(serviceID) → {Array.<String>}

Get the codes of available languages of a given service
Parameters:
Name Type Description
serviceID String The name of the service (the super-classe): "Info", "Lang", etc.
Returns:
Array.<String> - array of strings, with ISO639-2 codes

static nserv(serviceID, langCode) → {Class}

Get an object of a service class for a given language and service name.
For example: JsLingua.nserv("Info", "ara") Gives an object of the class AraInfo
Parameters:
Name Type Description
serviceID String The name of the service (the super-classe): "Info", "Lang", etc.
langCode String The language ISO639-2 code: "ara", "jpn", "eng", etc.
Returns:
Class - The class that affords the service