Lang

Module providing localization support throughout the framework. Allows client output to be translated to other languages

Source:

Properties

.langNames: string[]

Contains all available localization languages

Type:
string[]
Source:

.langs: object

Contains all loaded languages and their strings. This does not include localized command helptext. Rather than using this directly, loading stings with a ResourceLoader function is preferred

Type:
object
Source:

Methods

(static) .createInstance(client: Client) → void

Create the singleton instance. Called automatically by the YAMDBF Client at startup

Parameters:
Name Type Description
client
Client

YAMDBF Client instance

Source:
Returns:
void

(static) .createResourceLoader(lang: string)ResourceLoader

Takes a language string and returns a function that loads string resources for that specific language

Parameters:
Name Type Description
lang
string

The language to create a loader for

Source:
Returns:
ResourceLoader

(static) .getCommandInfo(command: Command, lang: string)LocalizedCommandInfo

Get localized Command info, defaulting to the info given in the Command's constructor

Parameters:
Name Type Description
command
Command

Command to get localized info for

lang
string

Language to get the localized info in

Source:
Returns:
LocalizedCommandInfo

(static) .getMetadata(lang: string) → object

Get all metadata for a given language

Parameters:
Name Type Description
lang
string

Language to get metadata for

Source:
Returns:
object

(static) .getMetaValue(lang: string, key: string) → any

Get a metadata value by key for a given language

Parameters:
Name Type Description
lang
string

Language to get metadata for

key
string

Metadata key to get

Source:
Returns:
any

(static) .loadCommandLocalizations() → void

Load any command localizations from the Client's commandsDir. Called automatically by the YAMDBF Client at startup

Source:
Returns:
void

(static) .loadCommandLocalizationsFrom(dir: string) → void

Load all command helptext localization files (*.lang.json) from the given directory. This can be used to manually load custom command helptext localizations from any given directory (when writing plugins, for instance)

Parameters:
Name Type Description
dir
string

Directory to load from

Source:
Returns:
void

(static) .loadLocalizations() → void

Load base localization files and load localization files from the Client's localeDir. Called automatically by the YAMDBF Client at startup

Source:
Returns:
void

(static) .loadLocalizationsFrom(dir: string) → void

Load all localization files (*.lang) from the given directory. This can be used to manually load custom localizations from any given directory (when writing plugins, for instance)

Parameters:
Name Type Description
dir
string

Directory to load from

Source:
Returns:
void

(static) .res(lang: string, key: string, data?: TemplateData) → string

Get a string resource for the given language, replacing any templates with the given data and evaluating any embedded template scripts

Parameters:
Name Type Attributes Description
lang
string

Language to get a string resource for

key
string

String key to get

data
TemplateData
<optional>

Values to replace in the string

Source:
Returns:
string

(static) .setMetaValue(lang: string, key: string, value: any) → void

Set a metadata key/value for a given language

Parameters:
Name Type Description
lang
string

Language to set metadata for

key
string

Metadata key to set

value
any

Metadata value to assign

Source:
Returns:
void