From 0ea3895b1620b3ad6620ec04b749f83a4d891c8d Mon Sep 17 00:00:00 2001 From: wuyangfan <1102042793@qq.com> Date: Tue, 26 May 2026 22:56:25 +0800 Subject: [PATCH] fix(web): localize scheduled routine empty-output errors Routine failure banners surfaced daemon English strings directly. Map the known empty-output message to i18n keys so zh locales render localized copy while other locales inherit the English fallback. Fixes #2902 --- apps/web/src/components/RoutinesSection.tsx | 21 ++++++++++------- apps/web/src/i18n/locales/en.ts | 2 ++ apps/web/src/i18n/locales/zh-CN.ts | 2 ++ apps/web/src/i18n/locales/zh-TW.ts | 2 ++ apps/web/src/i18n/runErrors.ts | 20 ++++++++++++++++ apps/web/src/i18n/types.ts | 1 + apps/web/tests/i18n/runErrors.test.ts | 26 +++++++++++++++++++++ 7 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 apps/web/src/i18n/runErrors.ts create mode 100644 apps/web/tests/i18n/runErrors.test.ts diff --git a/apps/web/src/components/RoutinesSection.tsx b/apps/web/src/components/RoutinesSection.tsx index e2f435da0..2d367d45a 100644 --- a/apps/web/src/components/RoutinesSection.tsx +++ b/apps/web/src/components/RoutinesSection.tsx @@ -12,6 +12,7 @@ import type { import { Icon } from './Icon'; import { navigate } from '../router'; import { useT } from '../i18n'; +import { localizeRunFailureReason } from '../i18n/runErrors'; import type { Dict } from '../i18n/types'; // Shared translator signature: every sub-component in this file is module-scoped, @@ -172,14 +173,16 @@ function formatRunTimestamp(ts: number): string { }); } -function runFailureReason(run: { - status: RoutineRun['status']; - error?: string | null; - summary?: string | null; -} | null | undefined): string | null { +function runFailureReason( + run: { + status: RoutineRun['status']; + error?: string | null; + summary?: string | null; + } | null | undefined, + t: TranslateFn, +): string | null { if (!run || run.status !== 'failed') return null; - const reason = (run.error || run.summary || '').trim(); - return reason || null; + return localizeRunFailureReason(run.error || run.summary || '', t); } type FormState = { @@ -412,7 +415,7 @@ function RunHistory({ return (