mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
## Summary Addresses two review comments from #6507: - **`timeUtils.ts`** — route relative time strings (`just now`, `Xm ago`, `Xh ago`, `Xd ago`) through i18n by accepting a `TFunction` parameter and using new `time.relative.*` keys in `en-GB` - **`ChatPanel.tsx`** — replace `ReturnType<typeof useTranslation>["t"]` with `TFunction` from `i18next` ## Test plan - [x] `task frontend:check` passes (695 tests)
This commit is contained in:
@@ -8151,6 +8151,12 @@ label = "Select a TSA server"
|
|||||||
[timestampPdf.steps]
|
[timestampPdf.steps]
|
||||||
settings = "Settings"
|
settings = "Settings"
|
||||||
|
|
||||||
|
[time.relative]
|
||||||
|
daysAgo = "{{count}}d ago"
|
||||||
|
hoursAgo = "{{count}}h ago"
|
||||||
|
justNow = "just now"
|
||||||
|
minutesAgo = "{{count}}m ago"
|
||||||
|
|
||||||
[tool]
|
[tool]
|
||||||
endpointUnavailable = "This tool is unavailable on your server."
|
endpointUnavailable = "This tool is unavailable on your server."
|
||||||
endpointUnavailableClickable = "Not available in this mode. Click to sign in."
|
endpointUnavailableClickable = "Not available in this mode. Click to sign in."
|
||||||
|
|||||||
@@ -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 diff = Date.now() - timestamp;
|
||||||
const mins = Math.floor(diff / 60_000);
|
const mins = Math.floor(diff / 60_000);
|
||||||
if (mins < 1) return "just now";
|
if (mins < 1) return t("time.relative.justNow");
|
||||||
if (mins < 60) return `${mins}m ago`;
|
if (mins < 60) return t("time.relative.minutesAgo", { count: mins });
|
||||||
const hours = Math.floor(mins / 60);
|
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);
|
const days = Math.floor(hours / 24);
|
||||||
return `${days}d ago`;
|
return t("time.relative.daysAgo", { count: days });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
type KeyboardEvent,
|
type KeyboardEvent,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { renderMarkdown } from "@app/components/viewer/nonpdf/MarkdownRenderer";
|
import { renderMarkdown } from "@app/components/viewer/nonpdf/MarkdownRenderer";
|
||||||
|
import { TFunction } from "i18next";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
@@ -43,7 +44,7 @@ import { StirlingLogoAnimated } from "@app/components/agents/StirlingLogoAnimate
|
|||||||
import { ChatQuickActions } from "@app/components/chat/ChatQuickActions";
|
import { ChatQuickActions } from "@app/components/chat/ChatQuickActions";
|
||||||
import "@app/components/chat/ChatPanel.css";
|
import "@app/components/chat/ChatPanel.css";
|
||||||
|
|
||||||
type TranslateFn = ReturnType<typeof useTranslation>["t"];
|
type TranslateFn = TFunction;
|
||||||
|
|
||||||
/** Resolver mapping a tool endpoint path to its translated display name. */
|
/** Resolver mapping a tool endpoint path to its translated display name. */
|
||||||
type ToolNameResolver = (endpoint: string) => string | null;
|
type ToolNameResolver = (endpoint: string) => string | null;
|
||||||
@@ -207,7 +208,7 @@ function ChatMessageBubble({
|
|||||||
<ContentCopyIcon sx={{ fontSize: 13 }} />
|
<ContentCopyIcon sx={{ fontSize: 13 }} />
|
||||||
</button>
|
</button>
|
||||||
<span className="chat-message-timestamp">
|
<span className="chat-message-timestamp">
|
||||||
{formatRelativeTime(timestamp)}
|
{formatRelativeTime(timestamp, t)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user