mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-01-22 20:18:30 +03:00
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:
parent
0f4ebb812e
commit
726ded74b6
@ -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 (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user