ILocalizer interface
Plugin for localizing messages sent to the user by a bot.
Methods
gettext(string, string, string) | Loads a localized string for the specified language. |
load(string, (err: Error) => void) | Loads the localized table for the supplied locale, and call's the supplied callback once the load is complete. |
ngettext(string, string, string, number, string) | Loads the plural form of a localized string for the specified language. |
trygettext(string, string, string) | Loads a localized string for the specified language. |
Method Details
gettext(string, string, string)
Loads a localized string for the specified language.
function gettext(locale: string, msgid: string, namespace?: string)
Parameters
- locale
-
string
Desired locale of the string to return.
- msgid
-
string
String to use as a key in the localized string table. Typically this will just be the english version of the string.
- namespace
-
string
(Optional) namespace for the msgid keys.
Returns
string
load(string, (err: Error) => void)
Loads the localized table for the supplied locale, and call's the supplied callback once the load is complete.
function load(locale: string, callback: (err: Error) => void)
Parameters
- locale
-
string
The locale to load.
- callback
-
(err: Error) => void
callback that is called once the supplied locale has been loaded, or an error if the load fails.
ngettext(string, string, string, number, string)
Loads the plural form of a localized string for the specified language.
function ngettext(locale: string, msgid: string, msgid_plural: string, count: number, namespace?: string)
Parameters
- locale
-
string
Desired locale of the string to return.
- msgid
-
string
Singular form of the string to use as a key in the localized string table.
- msgid_plural
-
string
Plural form of the string to use as a key in the localized string table.
- count
-
number
Count to use when determining whether the singular or plural form of the string should be used.
- namespace
-
string
(Optional) namespace for the msgid and msgid_plural keys.
Returns
string
trygettext(string, string, string)
Loads a localized string for the specified language.
function trygettext(locale: string, msgid: string, namespace?: string)
Parameters
- locale
-
string
Desired locale of the string to return.
- msgid
-
string
String to use as a key in the localized string table. Typically this will just be the english version of the string.
- namespace
-
string
(Optional) namespace for the msgid keys.
Returns
string