Constructor # new LanguageHandler() Source: handlers/LanguageHandler.js, line 24 Members # defaultLanguage :module:handlers/LanguageHandler~ISOLangCode ISO Language Code of the language to default to in cases in which the correct language to use cannot be determined. Type: module:handlers/LanguageHandler~ISOLangCode Source: handlers/LanguageHandler.js, line 46 Methods # (static) addLanguageFolder(languageFolder) Add a folder to scan for language files when language files are loaded. Parameters: Name Type Description languageFolder String The absolute path to the folder containing language files. Source: handlers/LanguageHandler.js, line 59 Example // Add "src/lang" to the list of folders to scan const { join } = require("path"); LanguageHandler.addLanguageFolder(join(__dirname, "src", "lang")); # (static) getCommandLocalisations(command) → {module:types~CommandLocalisationObject} Get the localisations of a command to provide to the Discord API. Parameters: Name Type Description command module:types~Command The command to retrieve localisations for. Source: handlers/LanguageHandler.js, line 211 Returns: The command's localisations. Type module:types~CommandLocalisationObject # (static) getCommandOptionLocalisations(command) → {module:types~CommandOptionLocalisationObject} Get the localistions of options of a command to provide to the Discord API. Parameters: Name Type Description command module:types~Command The command to retrieve localisations for. Source: handlers/LanguageHandler.js, line 242 Returns: The command's localisations. Type module:types~CommandOptionLocalisationObject # (static) getLocalisation(locale, path, …replaceopt) → {String} Get localised text. Parameters: Name Type Attributes Description locale module:handlers/LanguageHandler~ISOLangCode The ISO language code of the locale to use. path Array.<String> An array containing the path to the localisation. replace String <optional> <repeatable> Items to place within the localised text. Source: handlers/LanguageHandler.js, line 168 Returns: The localised text. Type String Example // Get a localised logging level name let name = LanguageHandler.getLocalisation("en", ["console", "logging", "debug"]); # (static) getLocalisationFromAPILocale(locale, path, …replaceopt) → {String} Get localised text with a locale defined by a Discord API locale.. Parameters: Name Type Attributes Description locale String | module:discord.js~Interaction The Discord API locale or Discord Interaction. path Array.<String> An array containing the path to the localisation. replace String <optional> <repeatable> Items to place within the localised text. Source: handlers/LanguageHandler.js, line 199 Returns: The localised text. Type String Example // Get a localised logging level name let name = LanguageHandler.getLocalisationFromAPILocale(interaction, ["console", "logging", "debug"]); let otherName = LanguageHandler.getLocalisationFromAPILocale("en-GB", ["console", "logging", "debug"]); # (static) loadAllLanguages(loggeropt) Clear any languages currently loaded and load all languages currently set to be used. Parameters: Name Type Attributes Description logger module:winston~Logger <optional> The logger being used (to report errors with language files). Source: handlers/LanguageHandler.js, line 89 Example // Load all languages in src/lang const { join } = require("path"); LanguageHandler.addLanguageFolder(join(__dirname, "src", "lang")); LanguageHandler.loadAllLanguages(); # (static) loadLanguageFile(filepath) Load an individual language file. Parameters: Name Type Description filepath String The path to the file to load. Source: handlers/LanguageHandler.js, line 114 Example // Load the default "en.lang" language file const { join } = require("path"); LanguageHandler.loadLanguageFile(join(__dirname, "lang", "en.lang"));