Module PLATE.Language

License Plate Language Handler

Module Overview

Functions

GetKey(bind[, default]) Get a given key for a binding.
Exists(code) Check if a language code exists.
PhraseExists(code, key) Check if a language phrase exists.
AddLanguage(code) Adds an empty language.
AddPhrase(code, key, phrase) Add a phrase to a language.
GetLanguage(code) Get a language with a given code.
GetLanguagePhrase(code, key) Get a phrase from a language.
PluralExists(code, key) Check if a language phrase exists.
GetLanguagePlural(code, key) Get a plural from a language.
Localise(code, key[, fallback]) Get a localised version of a string.
LocalisePlural(code, key[, fallback]) Get a localised version of a plural.
GeneratePlural(code, key[, fallback], num) Generate a plural, based on the language, key and number provided.
Interpolate(str[, stringable={}], code[, fallback]) Interpolate a language string.
GetLanguage() Get the primary language.
GetFallback() Get the default fallback language.
Register(iLang) Register a language.
__call(key[, stringable={}]) Localise a key.
New([code], pluralRuleID) Create a new language.
RegisterPluralRule(newRule) Register a plural rule.
GetPluralRule(id) Get the plural rule with the specified ID.

Functions

GetKey(bind[, default])
Get a given key for a binding.

Parameters:

  • bind string The bind (ex: +use) to search for.
  • default string Fallback value to display if no bind is found. (optional)
Exists(code)
Check if a language code exists.

Parameters:

Returns:

    bool If the language code exists.
PhraseExists(code, key)
Check if a language phrase exists.

Parameters:

Returns:

    bool If the phrase exists within the language.
AddLanguage(code)
Adds an empty language.

Parameters:

  • code string Language code to register under.
AddPhrase(code, key, phrase)
Add a phrase to a language.

Parameters:

  • code string Language code.
  • key string Unique locisation key.
  • phrase string Localised phrase.
GetLanguage(code)
Get a language with a given code.

Parameters:

Returns:

    lang
GetLanguagePhrase(code, key)
Get a phrase from a language.

Parameters:

  • code string Language code.
  • key string Unique localisation key.

Returns:

    optional string Localised string.
PluralExists(code, key)
Check if a language phrase exists.

Parameters:

Returns:

    bool If the phrase exists within the language.
GetLanguagePlural(code, key)
Get a plural from a language.

Parameters:

  • code string Language code.
  • key string Unique localisation key.

Returns:

    optional plural Plural
Localise(code, key[, fallback])
Get a localised version of a string.

Parameters:

  • code string Language code to fetch for.
  • key string Phrase key to fetch.
  • fallback string Fallback language key if the phrase doesn't exist here. (optional)
LocalisePlural(code, key[, fallback])
Get a localised version of a plural.

Parameters:

  • code string Language code to fetch for.
  • key string Plural key to fetch.
  • fallback string Fallback language key if the plural doesn't exist here. (optional)
GeneratePlural(code, key[, fallback], num)
Generate a plural, based on the language, key and number provided.

Parameters:

  • code string Language to fetch.
  • key string Language key to fetch.
  • fallback string Fallback language if the plural doesn't exist in your language. (optional)
  • num number The number of items in the plural.

Returns:

    string Generated plural, ?? if an error occurs.
Interpolate(str[, stringable={}], code[, fallback])
Interpolate a language string. The language string must be in the form "regular text {{pluralKey|number}} {{dataKey}} {{languageKey}}". pluralKeys are localised with the number passed as the second argument. For example, if "computer" was a key, {{computer|2}} would become "computers". dataKeys are interpolated with variables from the data parameter. data = {name = "John"}, str = "Hello {{name}}" -> "Hello John". If neither of these fit, then it's passed back to the localisation system as a key. If none of these work, it is replaced with "??".

Parameters:

Returns:

    string Localised String.
GetLanguage()
Get the primary language.

Returns:

    string Language Code.
GetFallback()
Get the default fallback language.

Returns:

    string Language Code.
Register(iLang)
Register a language.

Parameters:

  • iLang lang New language to register.
__call(key[, stringable={}])
Localise a key.

Parameters:

Returns:

    string Localised string.
New([code], pluralRuleID)
Create a new language.

Parameters:

  • code string Language code to register. (optional)
  • pluralRuleID number The ID of the plural rule this language uses.

Returns:

    lang
RegisterPluralRule(newRule)
Register a plural rule.

Parameters:

  • newRule rule Plural rule to register.
GetPluralRule(id)
Get the plural rule with the specified ID.

Parameters:

  • id number Plural rule ID.

Returns:

    optional rule