DuAEF.Dutranslator

The Javascript translator part of the Dutranslator Framework
see https://github.com/Rainbox-dev/Dutranslator

Namespaces

Settings

Members

static current

The current language id (fr, en, ..)

static currentName

The current language name

static languages

A map containing available languages. There is a language name and a file name for each language id. languages["fr_FR"] ["name"] is "Francais" for example. Will be filled when executing Dutranslator.getAvailable().

static localizedStrings

The translated strings of the current language An array of compounds containing the source, the translation and the context

Methods

static generateTranslationFile(translationsopt, file, appNameopt, versionopt, languageIdopt, languageNameopt)

Creates a file for translation with the given base strings.
Parameters:
Name Type Attributes Default Description
translations Array.<Translation> | strings <optional>
DuAEF.Dutranslator.localizedStrings The translations or source strings to be included in the translation file.
file File | string The file or URI
appName string <optional>
"dutranslator" A name for the app using this translation file.
version string <optional>
"0.0" A version (as a string) for this translation file or app.
languageId string <optional>
DuAEF.Dutranslator.current A version (as a string) for this translation file or app.
languageName string <optional>
DuAEF.Dutranslator.currentName A version (as a string) for this translation file or app.

static generateTranslations(strings) → {Array.<Translation>}

Converts an Array of strings to an Array of empty translations
Parameters:
Name Type Description
strings Array.<string> The base strings to convert.
Returns:
Array.<Translation> - The empty translations

static getAvailable()

Load the list of available languages If the language id and or the language name can't be found in the file, the file name will be used to determine the language id and the name will be set as the id.
Returns:
- A success code 0 Success 1 One of the file haven't been correctly opened

static getLanguageId(prettyName)

Returns the language id of a given language name
Parameters:
Name Type Description
prettyName string The pretty name of the request language

static getPrettyName(langId)

Returns the pretty name of a given language
Parameters:
Name Type Description
langId string The id of the request language

static getPrettyNames(langId)

Returns a list containing pretty names of all languages
Parameters:
Name Type Description
langId string The id of the request language

static setLanguage(languageId)

Set the current language
Parameters:
Name Type Description
languageId string The id of the language to set
Returns:
- success code 0 Everything went ok 1 The file linked to the given id can't be opened 2 The json content doesn't match a translation file

static setPrettyLanguage(languageName)

Set the current language with a given pretty name
Parameters:
Name Type Description
languageName string The pretty name of the language to set
Returns:
- success code 0 Everything went ok -1 Can't find any language with the given pretty name >0 Call to setLanguage(languageId) failed