ability to lowercase output for names

This commit is contained in:
Mylloon 2022-07-24 15:42:25 +02:00
parent a8ce8faf06
commit b085539b48
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -53,18 +53,21 @@ export const loadLocales = async (default_lang: string) => {
* @param text Name of string to fetch
* @returns the dictionary
*/
export const getLocalizations = (client: Client, text: string) => {
export const getLocalizations = (client: Client, text: string, lowercase = false) => {
const data: Record<string, string> = {};
// Load all the localizations
client.locales.forEach((locale, lang) => {
// Fetch the text and fallback to default lang if needed
// 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);
// Store it if defined
if (str !== undefined) {
if (lowercase) {
str = str.toLowerCase();
}
data[lang] = str;
}
});