mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +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:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user