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. |
- GetKey(bind[, default])
-
Get a given key for a binding.
Parameters:
- Exists(code)
-
Check if a language code exists.
Parameters:
- code string Language code.
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:
- GetLanguage(code)
-
Get a language with a given code.
Parameters:
- code string Language code.
Returns:
- GetLanguagePhrase(code, key)
-
Get a phrase from a language.
Parameters:
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:
Returns:
-
optional plural
Plural
- Localise(code, key[, fallback])
-
Get a localised version of a string.
Parameters:
- LocalisePlural(code, key[, fallback])
-
Get a localised version of a plural.
Parameters:
- 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:
- str string String to interpolate.
- stringable
table
(default {})data A string keyed table of stringable parameters to pass into the localised string.
- code string Language to use.
- fallback string Fallback language. (optional)
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:
- key string Key to localise.
- stringable
table
(default {})data A string keyed table of stringable parameters to pass into the localised string.
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:
- 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