Skip to content

Commit b671a09

Browse files
committed
Fix i18n interpolation for notifications (case-insensitive keys)
1 parent a6b5b81 commit b671a09

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/components/layout/NotificationDropdown.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ export default function NotificationDropdown({ isOpen, setIsOpen, isLoggedIn }:
6969
// Use i18n key based on type if available in translation file
7070
const key = `navbar.notifications.types.${notif.type}`;
7171

72-
// We pass the entire data object as values for interpolation.
73-
// E.g. { sender: "Alice", team: "Alpha", contest: "Cyber League" }
74-
// This assumes backend sends these keys in `notif.data`.
75-
// If `notif.data` is missing or keys don't match, we fallback to `notif.message`.
76-
const translated = t(key, notif.data || {});
72+
const data = notif.data || {};
73+
// Normalize keys to lowercase to support case-insensitive interpolation
74+
// (e.g. "Sender" -> "sender", "Team" -> "team")
75+
const normalizedData = Object.keys(data).reduce((acc, k) => {
76+
acc[k.toLowerCase()] = data[k];
77+
return acc;
78+
}, { ...data });
79+
80+
const translated = t(key, normalizedData);
7781

7882
// If the key doesn't exist (returns the key itself), fallback to the message from backend
7983
if (translated === key) return notif.message;

0 commit comments

Comments
 (0)