improve i18n key fallback when translation files aren't loaded

just display a valid time now instead of "invalid time"
This commit is contained in:
Josh Hawkins 2025-12-28 08:48:51 -06:00
parent 0f4ebb812e
commit 726ded74b6

View File

@ -79,6 +79,24 @@ i18n
parseMissingKeyHandler: (key: string) => { parseMissingKeyHandler: (key: string) => {
const parts = key.split("."); 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<string, string> = {
"12hour": "h:mm aaa",
"24hour": "HH:mm",
};
if (formatDefaults[formatType]) {
return formatDefaults[formatType];
}
}
// Handle special cases for objects and audio // Handle special cases for objects and audio
if (parts[0] === "object" || parts[0] === "audio") { if (parts[0] === "object" || parts[0] === "audio") {
return ( return (