From 719d06b93745d4ad9eb6b6c6ebefad2847b692e6 Mon Sep 17 00:00:00 2001 From: dev-737 <73829355+dev-737@users.noreply.github.com> Date: Mon, 1 Jan 2024 21:37:34 +0530 Subject: [PATCH] fix: add hindi locale --- locales | 2 +- src/commands/slash/Main/setlanguage.ts | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/locales b/locales index dcffe4ac..3ca7412a 160000 --- a/locales +++ b/locales @@ -1 +1 @@ -Subproject commit dcffe4ac87f91958cb50ab5272133e5320649c96 +Subproject commit 3ca7412a2f137265b25dd60ac6edc5c828c0ce04 diff --git a/src/commands/slash/Main/setlanguage.ts b/src/commands/slash/Main/setlanguage.ts index ef502047..a4132b23 100644 --- a/src/commands/slash/Main/setlanguage.ts +++ b/src/commands/slash/Main/setlanguage.ts @@ -8,6 +8,12 @@ import db from '../../../utils/Db.js'; import { emojis } from '../../../utils/Constants.js'; import { t } from '../../../utils/Locale.js'; +const locales = { + en: '🇺🇸 English', + tr: '🇹🇷 Turkish', + hi: '🇮🇳 Hindi', +}; + export default class SetLanguage extends BaseCommand { data: RESTPostAPIApplicationCommandsJSONBody = { name: 'setlanguage', @@ -18,16 +24,13 @@ export default class SetLanguage extends BaseCommand { description: 'The language to set', type: ApplicationCommandOptionType.String, required: true, - choices: [ - { name: '🇺🇸 English', value: 'en' }, - { name: '🇹🇷 Turkish', value: 'tr' }, - ], + choices: Object.entries(locales).map((locale) => ({ name: locale[1], value: locale[0] })), }, ], }; async execute(interaction: ChatInputCommandInteraction) { - const locale = interaction.options.getString('lang', true); + const locale = interaction.options.getString('lang', true) as keyof typeof locales; await db.userData.upsert({ where: { userId: interaction.user.id }, create: { @@ -40,7 +43,7 @@ export default class SetLanguage extends BaseCommand { }, }); - const lang = locale === 'en' ? '🇺🇸 English' : '🇹🇷 Turkish'; + const lang = locales[locale]; await interaction.reply({ content: emojis.yes + t({ phrase: 'language.set', locale }, { lang }),