From e9dc622cc325f3a16b3f60ea924da566ba4fdb4f Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Wed, 15 Oct 2025 13:08:31 -0500 Subject: [PATCH] ensure i18n audio label keys are translated don't assume they are in the objects namespace --- web/src/utils/i18n.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/web/src/utils/i18n.ts b/web/src/utils/i18n.ts index 8ee059333..44e9fe77b 100644 --- a/web/src/utils/i18n.ts +++ b/web/src/utils/i18n.ts @@ -5,7 +5,21 @@ import HttpBackend from "i18next-http-backend"; export const getTranslatedLabel = (label: string) => { if (!label) return ""; - return t(`${label.replace(/\s+/g, "_").toLowerCase()}`, { ns: "objects" }); + const normalize = (s: string) => + s + .trim() + .replace(/[-'\s]+/g, "_") + .replace(/__+/g, "_") + .replace(/^_+|_+$/g, "") + .toLowerCase(); + + const key = normalize(label); + + if (i18n.exists(key, { ns: "objects" })) return t(key, { ns: "objects" }); + if (i18n.exists(key, { ns: "audio" })) return t(key, { ns: "audio" }); + + // fallback + return t(key, { ns: "objects" }); }; i18n