Module providing localization support throughout the framework. Allows client output to be translated to other languages
- Source:
Properties
.langNames: string[]
.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
- Source:
Methods
(static) .createInstance(client: Client) → void
Create the singleton instance. Called automatically by the YAMDBF Client at startup
Parameters:
Name | Type | Description |
---|---|---|
client |
|
YAMDBF Client instance |
- Source:
(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 |
|
The language to create a loader for |
- Deprecated:
- Use
module:Lang.createResourceProxy
instead
- Use
- Source:
(static) .createResourceProxy(Lang: string) → ResourceProxy
Creates a ResourceProxy, where keys are ResourceLoader functions that only need the TemplateData
Parameters:
Name | Type | Description |
---|---|---|
Lang |
|
The language to create a ResourceProxy for |
- Source:
(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 to get localized info for |
lang |
|
Language to get the localized info in |
- Source:
(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 |
|
- Source:
(static) .getMetadata(lang: string) → object
Get all metadata for a given language
Parameters:
Name | Type | Description |
---|---|---|
lang |
|
Language to get metadata for |
- Source:
(static) .getMetaValue(lang: string, key: string) → any
Get a metadata value by key for a given language
Parameters:
Name | Type | Description |
---|---|---|
lang |
|
Language to get metadata for |
key |
|
Metadata key to get |
- Source:
(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:
(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 |
|
Directory to load from |
- Source:
(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 |
|
Directory to load from |
- Source:
(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:
(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 |
|
Directory to load from |
- Source:
(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 |
|
Language to get a string resource for |
|
key |
|
String key to get |
|
data |
|
<optional> |
Values to replace in the string |
- Source:
(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 |
|
Fallback language to set |
- Source:
(static) .setMetaValue(lang: string, key: string, value: any) → void
Set a metadata key/value for a given language
Parameters:
Name | Type | Description |
---|---|---|
lang |
|
Language to set metadata for |
key |
|
Metadata key to set |
value |
|
Metadata value to assign |
- Source: