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

Deprecated:
Source:
Returns:
ResourceLoader

(static) .createResourceProxy(Lang: string)ResourceProxy

Creates a ResourceProxy, where keys are ResourceLoader functions that only need the TemplateData

Parameters:
Name Type Description
Lang
string

The language to create a ResourceProxy for

Source:
Returns:
ResourceProxy

(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) .getLangFromMessage(message: Message) → Promise<string>

Gets the language that should be used for localization via the given Message based on whether the Message is a DM, the Guild's configured language, and the Client's default language

Parameters:
Name Type Description
message
Message
Source:
Returns:
Promise<string>

(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 info and command group 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) .loadGroupLocalizationsFrom(dir: string) → void

Find and load commandgroups.lang.json from the provided directory, setting command group descriptions for the given groups and languages in the file

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) .setFallbackLang(lang: string) → void

Set the language to try when a string cannot be found for the current language

Parameters:
Name Type Description
lang
string

Fallback language to set

Source:
Returns:
void

(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