diff --git a/frontend/editor/public/locales/en-GB/translation.toml b/frontend/editor/public/locales/en-GB/translation.toml index d2aa0300d..d1f4ecab8 100644 --- a/frontend/editor/public/locales/en-GB/translation.toml +++ b/frontend/editor/public/locales/en-GB/translation.toml @@ -8151,6 +8151,12 @@ label = "Select a TSA server" [timestampPdf.steps] settings = "Settings" +[time.relative] +daysAgo = "{{count}}d ago" +hoursAgo = "{{count}}h ago" +justNow = "just now" +minutesAgo = "{{count}}m ago" + [tool] endpointUnavailable = "This tool is unavailable on your server." endpointUnavailableClickable = "Not available in this mode. Click to sign in." diff --git a/frontend/editor/src/core/utils/timeUtils.ts b/frontend/editor/src/core/utils/timeUtils.ts index 7bca31100..b38c4c267 100644 --- a/frontend/editor/src/core/utils/timeUtils.ts +++ b/frontend/editor/src/core/utils/timeUtils.ts @@ -1,10 +1,12 @@ -export function formatRelativeTime(timestamp: number): string { +import { TFunction } from "i18next"; + +export function formatRelativeTime(timestamp: number, t: TFunction): string { const diff = Date.now() - timestamp; const mins = Math.floor(diff / 60_000); - if (mins < 1) return "just now"; - if (mins < 60) return `${mins}m ago`; + if (mins < 1) return t("time.relative.justNow"); + if (mins < 60) return t("time.relative.minutesAgo", { count: mins }); const hours = Math.floor(mins / 60); - if (hours < 24) return `${hours}h ago`; + if (hours < 24) return t("time.relative.hoursAgo", { count: hours }); const days = Math.floor(hours / 24); - return `${days}d ago`; + return t("time.relative.daysAgo", { count: days }); } diff --git a/frontend/editor/src/proprietary/components/chat/ChatPanel.tsx b/frontend/editor/src/proprietary/components/chat/ChatPanel.tsx index 2e1d00e8e..7baf5d0a5 100644 --- a/frontend/editor/src/proprietary/components/chat/ChatPanel.tsx +++ b/frontend/editor/src/proprietary/components/chat/ChatPanel.tsx @@ -6,6 +6,7 @@ import { type KeyboardEvent, } from "react"; import { renderMarkdown } from "@app/components/viewer/nonpdf/MarkdownRenderer"; +import { TFunction } from "i18next"; import { useTranslation } from "react-i18next"; import { ActionIcon, @@ -43,7 +44,7 @@ import { StirlingLogoAnimated } from "@app/components/agents/StirlingLogoAnimate import { ChatQuickActions } from "@app/components/chat/ChatQuickActions"; import "@app/components/chat/ChatPanel.css"; -type TranslateFn = ReturnType["t"]; +type TranslateFn = TFunction; /** Resolver mapping a tool endpoint path to its translated display name. */ type ToolNameResolver = (endpoint: string) => string | null; @@ -207,7 +208,7 @@ function ChatMessageBubble({ - {formatRelativeTime(timestamp)} + {formatRelativeTime(timestamp, t)} );