feat: help command #36
1 changed files with 5 additions and 2 deletions
|
@ -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;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue