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 |
- 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) .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 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) .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) .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: