From 726ded74b633428fce19d3b6f0ac4cfdfa22f274 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 28 Dec 2025 08:48:51 -0600 Subject: [PATCH] improve i18n key fallback when translation files aren't loaded just display a valid time now instead of "invalid time" --- web/src/utils/i18n.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web/src/utils/i18n.ts b/web/src/utils/i18n.ts index eba5ff7a5..ca7ad8e25 100644 --- a/web/src/utils/i18n.ts +++ b/web/src/utils/i18n.ts @@ -79,6 +79,24 @@ i18n parseMissingKeyHandler: (key: string) => { const parts = key.split("."); + // eslint-disable-next-line no-console + console.warn(`Missing translation key: ${key}`); + + if (parts[0] === "time" && parts[1]?.includes("formattedTimestamp")) { + // Extract the format type from the last part (12hour, 24hour) + const formatType = parts[parts.length - 1]; + + // Return actual date-fns format strings as fallbacks + const formatDefaults: Record = { + "12hour": "h:mm aaa", + "24hour": "HH:mm", + }; + + if (formatDefaults[formatType]) { + return formatDefaults[formatType]; + } + } + // Handle special cases for objects and audio if (parts[0] === "object" || parts[0] === "audio") { return (