feat: help command #36

Merged
Anri merged 23 commits from help into main 2022-07-25 00:54:19 +02:00
Showing only changes of commit b085539b48 - Show all commits

View file

@ -53,18 +53,21 @@ export const loadLocales = async (default_lang: string) => {
* @param text Name of string to fetch * @param text Name of string to fetch
* @returns the dictionary * @returns the dictionary
*/ */
export const getLocalizations = (client: Client, text: string) => { export const getLocalizations = (client: Client, text: string, lowercase = false) => {
const data: Record<string, string> = {}; const data: Record<string, string> = {};
// Load all the localizations // Load all the localizations
client.locales.forEach((locale, lang) => { client.locales.forEach((locale, lang) => {
// Fetch the text and fallback to default lang if needed // Fetch the text and fallback to default lang if needed
// See getLocale for more info on why we *can* fallback // See getLocale for more info on why we *can* fallback
const str = locale.get(text) let str = locale.get(text)
?? client.locales.get(client.config.default_lang)?.get(text); ?? client.locales.get(client.config.default_lang)?.get(text);
// Store it if defined // Store it if defined
if (str !== undefined) { if (str !== undefined) {
if (lowercase) {
str = str.toLowerCase();
}
data[lang] = str; data[lang] = str;
} }
}); });