From e24dc5b01b6275f7d7ab9559260f8f8050eaf541 Mon Sep 17 00:00:00 2001 From: Baobhan Sith <80159437+Heavrnl@users.noreply.github.com> Date: Sat, 26 Apr 2025 08:34:40 +0800 Subject: [PATCH] Update NotificationSettings.vue --- .../src/components/NotificationSettings.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/NotificationSettings.vue b/packages/frontend/src/components/NotificationSettings.vue index 2d0392e..e0dd014 100644 --- a/packages/frontend/src/components/NotificationSettings.vue +++ b/packages/frontend/src/components/NotificationSettings.vue @@ -97,10 +97,23 @@ const getChannelTypeName = (type: NotificationChannelType): string => { } }; +// Helper function to translate a single event name +const getSingleEventDisplayName = (event: NotificationEvent): string => { + const i18nKey = `settings.notifications.events.${event}`; + const translated = t(i18nKey); + // Fallback if translation is missing + if (translated === i18nKey) { + console.warn(`Missing translation for notification event: ${i18nKey}`); + return event.replace(/_/g, ' ').toLowerCase().replace(/\b\w/g, l => l.toUpperCase()); + } + return translated; +}; + const getEventNames = (events: NotificationEvent[]): string => { if (!events || events.length === 0) return t('settings.notifications.noEventsEnabled'); - // TODO: Translate event names if needed - return t('settings.notifications.triggers') + ': ' + events.join(', '); + // Translate each event name + const translatedNames = events.map(event => getSingleEventDisplayName(event)); + return t('settings.notifications.triggers') + ': ' + translatedNames.join(', '); }; const editSetting = (setting: NotificationSetting) => {