PEP-98: relative times in the interface language everywhere

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-15 15:23:19 +05:00
parent 1b0f6063cb
commit f107929a14
6 changed files with 16 additions and 17 deletions

View File

@ -149,7 +149,7 @@ export default async function ChatPage({ params, searchParams }: { params: Promi
<ThreadLink href={url({ thread: CHANNEL })} active={thread === null} title={t("# Канал")} />
{threads.length > 0 && <div className="mx-2 my-1 border-t" />}
{threads.map((th) => (
<ThreadLink key={th.key} href={url({ thread: th.key })} active={thread === th.key} title={t.text(th.title)} meta={`${th.count} · ${ago(th.lastAt)}`} open={th.open} />
<ThreadLink key={th.key} href={url({ thread: th.key })} active={thread === th.key} title={t.text(th.title)} meta={`${th.count} · ${ago(th.lastAt, t)}`} open={th.open} />
))}
{threads.length === 0 && <p className="m-0 px-2 py-1.5 text-xs text-muted-foreground">{t("Тредов пока нет.")}</p>}
</nav>
@ -232,7 +232,7 @@ async function MessageItem({ m, q, back, showThread, masterView }: { m: ChatMess
🧵 {label}
</Link>
)}
<span className="ml-auto font-mono">{ago(m.createdAt)}</span>
<span className="ml-auto font-mono">{ago(m.createdAt, t)}</span>
</div>
);
if (q) {

View File

@ -180,7 +180,7 @@ export default async function StoryPage({ params, searchParams }: { params: Prom
<PanelSection title={t("Ревьюер")}>
<p className="m-0 text-sm [overflow-wrap:anywhere]">{t.text(reviewLabel(review))}</p>
<p className="m-0 text-xs text-muted-foreground">
{review.sha.slice(0, 7)} · {ago(review.updatedAt)}
{review.sha.slice(0, 7)} · {ago(review.updatedAt, t)}
</p>
</PanelSection>
)}

View File

@ -158,7 +158,7 @@ export async function CommentsTab({ taskKey, taskStatus, questions, comments, ba
<article key={`c${x.c.id}`} data-role={x.c.role} className={cn("flex flex-col gap-1.5 rounded-lg border p-3.5", x.c.role ? "border-info/40 bg-info/[0.06]" : "border-primary/30 bg-primary/[0.04]")}>
<header className="flex items-center gap-2 text-xs text-muted-foreground">
{x.c.role ? <AgentBadge name={x.c.login} className="font-medium text-foreground" /> : <MessageSquare className="size-3.5 text-primary" />}
{x.c.role ? (x.c.role === "product" ? t("зачем и что берём") : t("что должно получиться")) : <><span className="font-medium text-foreground">{x.c.login}</span> {t("комментарий PM")}</>} · {ago(x.c.createdAt)}
{x.c.role ? (x.c.role === "product" ? t("зачем и что берём") : t("что должно получиться")) : <><span className="font-medium text-foreground">{x.c.login}</span> {t("комментарий PM")}</>} · {ago(x.c.createdAt, t)}
</header>
<p className="m-0 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]">{x.c.text}</p>
</article>
@ -244,7 +244,7 @@ export async function TestsTab({ ci, runs, review }: { ci: CiSummary; runs: Chec
{review.verdict === "ok" ? STATE_ICON.success : review.verdict === "changes" || review.state === "error" ? STATE_ICON.failure : STATE_ICON.pending}
<span className="[overflow-wrap:anywhere]">{t.text(reviewLabel(review))}</span>
<span className="font-mono text-xs text-muted-foreground">
{review.sha.slice(0, 7)} · {ago(review.updatedAt)}
{review.sha.slice(0, 7)} · {ago(review.updatedAt, t)}
</span>
</p>
{review.summary && <Markdown text={review.summary} className="text-xs" />}
@ -274,7 +274,7 @@ async function CheckLine({ r }: { r: CheckRunRow }) {
{STATE_ICON[r.state]}
<span className="font-mono">{r.check}</span>
{r.durationSec != null && <span className="font-mono text-xs text-muted-foreground">{t("{n} с", { n: r.durationSec })}</span>}
<span className="ml-auto font-mono text-xs text-muted-foreground">{ago(r.updatedAt)}</span>
<span className="ml-auto font-mono text-xs text-muted-foreground">{ago(r.updatedAt, t)}</span>
{r.runUrl && (
<a href={r.runUrl} className="text-xs text-primary">
{t("лог")}
@ -415,7 +415,7 @@ export async function ActivityTab({ events, authors }: { events: ActivityEvent[]
return (
<li key={e.id} className="relative py-1.5 text-sm [overflow-wrap:anywhere]">
<span className={cn("absolute top-3 -left-[1.3rem] size-2 rounded-full", a.tone === "pm" ? "bg-primary" : a.tone === "agent" ? "bg-info" : "bg-muted-foreground")} />
<span className="font-mono text-xs text-muted-foreground">{ago(e.createdAt)}</span> <span className={cn("text-xs font-medium", a.tone === "pm" ? "text-primary" : a.tone === "agent" ? "text-info" : "text-muted-foreground")}>{a.label}</span>{" "}
<span className="font-mono text-xs text-muted-foreground">{ago(e.createdAt, t)}</span> <span className={cn("text-xs font-medium", a.tone === "pm" ? "text-primary" : a.tone === "agent" ? "text-info" : "text-muted-foreground")}>{a.label}</span>{" "}
<span className="font-mono text-xs text-muted-foreground">{EVENT_RU[e.type] ? t(EVENT_RU[e.type]) : e.type}</span> {changeLine(e, t)}
</li>
);

View File

@ -146,7 +146,7 @@ async function IncidentCard({ i, back, projectId, taskKeys }: { i: Incident; bac
<div className="flex items-start gap-2">
<Badge variant={STATUS_TONE[i.status]}>{t(INCIDENT_STATUS_RU[i.status])}</Badge>
<b className="min-w-0 flex-1 font-mono text-[13px] font-medium [overflow-wrap:anywhere]">{i.title}</b>
<span className="shrink-0 font-mono text-xs text-muted-foreground">{ago(i.lastSeen)}</span>
<span className="shrink-0 font-mono text-xs text-muted-foreground">{ago(i.lastSeen, t)}</span>
</div>
<div className="flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground">
{i.source} · {i.environment ?? "—"} · {t("релиз {release}", { release: i.lastRelease ?? "—" })} · {t("событий {n}", { n: i.events })}

View File

@ -94,7 +94,7 @@ export async function RunnerRow({ s, href, selected, needsPm }: { s: SessionView
<span className="truncate font-mono text-[11px] text-muted-foreground">
{s.name && s.taskTitle ? `${s.name} · ` : ""}{s.projectKey} · {s.provider}{s.subscriptionName ? ` · ${s.subscriptionName}` : ""}{s.subscriptionSwitches > 0 ? ` (↻${s.subscriptionSwitches})` : ""} · #{s.id} · {s.tmuxName}
</span>
<span className="text-right font-mono text-[11px] whitespace-nowrap text-muted-foreground">{ago(s.lastActivityAt)}</span>
<span className="text-right font-mono text-[11px] whitespace-nowrap text-muted-foreground">{ago(s.lastActivityAt, t)}</span>
{limited && (
<span className="col-span-2 col-start-2 font-mono text-[11px] text-warn sm:hidden">
<LimitNote s={s} />
@ -159,9 +159,9 @@ export async function RunnerDetails({ s, questions, events, steps, stories, back
{s.container ? <span className="text-muted-foreground"> · {t("контейнер {name}", { name: s.container })}</span> : <span className="text-muted-foreground"> · {t("без изоляции")}</span>}
</dd>
<dt className="text-muted-foreground">{t("Запущен")}</dt>
<dd className="m-0">{ago(s.startedAt)}</dd>
<dd className="m-0">{ago(s.startedAt, t)}</dd>
<dt className="text-muted-foreground">{t("Активность")}</dt>
<dd className="m-0">{ago(s.lastActivityAt)}</dd>
<dd className="m-0">{ago(s.lastActivityAt, t)}</dd>
</dl>
<AttachCommand name={s.tmuxName} />
@ -198,7 +198,7 @@ export async function RunnerDetails({ s, questions, events, steps, stories, back
.filter((e) => e.type === "subscription_switched")
.map((e) => (
<li key={e.id} className="text-sm [overflow-wrap:anywhere]">
<span className="font-mono text-xs text-muted-foreground">{ago(e.createdAt)}</span> {switchText(e.payload, t)}
<span className="font-mono text-xs text-muted-foreground">{ago(e.createdAt, t)}</span> {switchText(e.payload, t)}
</li>
))}
</ol>
@ -210,7 +210,7 @@ export async function RunnerDetails({ s, questions, events, steps, stories, back
<ol className="m-0 flex list-none flex-col gap-1.5 border-l p-0 pl-3">
{events.map((e) => (
<li key={e.id} className="text-xs [overflow-wrap:anywhere]">
<span className="font-mono text-muted-foreground">{ago(e.createdAt)}</span> <span className="font-mono text-primary">{e.type}</span>{" "}
<span className="font-mono text-muted-foreground">{ago(e.createdAt, t)}</span> <span className="font-mono text-primary">{e.type}</span>{" "}
{eventLine(e, t)}
</li>
))}

View File

@ -6,7 +6,7 @@ import { Badge } from "@/components/ui/badge";
import { SESSION_STATUS, TASK_STATUS, TONE_BG } from "@/lib/status";
import { cn } from "@/lib/utils";
import { getT } from "@/lib/i18n";
import { intlLocale, translator, type Translator } from "@peppa/shared/i18n";
import { intlLocale, type Translator } from "@peppa/shared/i18n";
export function PageHeader({ title, crumbs, actions, children }: { title: ReactNode; crumbs?: ReactNode; actions?: ReactNode; children?: ReactNode }) {
return (
@ -96,10 +96,9 @@ export function Disclosure({ summary, children, open, className }: { summary: Re
);
}
const ruT = translator("ru");
/** «5 мин назад»; pass the page's translator for its language (Russian without one). */
export function ago(d: Date | null | undefined, t: Translator = ruT): string {
/** «5 мин назад» in the page's language. */
export function ago(d: Date | null | undefined, t: Translator): string {
if (!d) return "—";
const s = Math.round((Date.now() - d.getTime()) / 1000);
if (s < 60) return t("{n} с назад", { n: s });