From 28f6a1fd250de2f628dd1149434a2860ae42471d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Salavisa?= Date: Fri, 7 Aug 2026 17:24:56 +0200 Subject: [PATCH] fix(i18n): pass the routine cron example through as a value (#2373) Co-authored-by: Kandev Agent Co-authored-by: Claude Opus 5 (1M context) --- .../create-routine-dialog.i18n.test.ts | 39 +++++++++++++++++++ .../office/routines/create-routine-dialog.tsx | 9 ++++- apps/web/src/locales/en/office.json | 2 +- apps/web/src/locales/pseudo/office.json | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 apps/web/app/office/routines/create-routine-dialog.i18n.test.ts diff --git a/apps/web/app/office/routines/create-routine-dialog.i18n.test.ts b/apps/web/app/office/routines/create-routine-dialog.i18n.test.ts new file mode 100644 index 0000000000..ed2c2d6d81 --- /dev/null +++ b/apps/web/app/office/routines/create-routine-dialog.i18n.test.ts @@ -0,0 +1,39 @@ +import { describe, expect, it } from "vitest"; + +import { t } from "@/lib/i18n"; +import enOffice from "@/src/locales/en/office.json"; +import pseudoOffice from "@/src/locales/pseudo/office.json"; + +/** + * A cron expression is syntax, not copy. Baked into a catalog message a + * translator can reorder its fields, localise `MON`, or insert a space and ship + * an example no cron parser accepts — and the pseudo-locale mangles it outright. + * Both office cron examples therefore carry the expression as a `values` entry. + * + * `standardCronExpressionExample` is rendered by the routine trigger fields in + * `create-routine-dialog.tsx`; `aCronScheduleExample` by the routine editor. + */ +describe("office cron example messages", () => { + const CRON_KEYS = ["standardCronExpressionExample", "aCronScheduleExample"] as const; + + /** Five whitespace-separated cron fields — what must never appear in a message. */ + const CRON_SHAPED = /[\d*/,-]+\s+[\d*/,-]+\s+[\d*/,-]+\s+[\d*/,-]+\s+[\dA-Z*/,-]+/; + + it.each(CRON_KEYS)("keeps the cron expression out of the en message for %s", (key) => { + const message: string = enOffice[key]; + expect(message).toContain("{{cron}}"); + expect(message).not.toMatch(CRON_SHAPED); + }); + + it.each(CRON_KEYS)("keeps {{cron}} verbatim in the pseudo message for %s", (key) => { + // The placeholder surviving transliteration is the proof the value is + // substituted at render rather than living inside the translated text. + expect(pseudoOffice[key]).toContain("{{cron}}"); + }); + + it("renders the dialog hint byte-identically to the pre-extraction English", () => { + expect(t("office:standardCronExpressionExample", { cron: "0 9 * * MON" })).toBe( + "Standard cron expression (e.g. 0 9 * * MON for every Monday at 9am)", + ); + }); +}); diff --git a/apps/web/app/office/routines/create-routine-dialog.tsx b/apps/web/app/office/routines/create-routine-dialog.tsx index 1d6c6e3d6d..3adc178671 100644 --- a/apps/web/app/office/routines/create-routine-dialog.tsx +++ b/apps/web/app/office/routines/create-routine-dialog.tsx @@ -224,7 +224,14 @@ function TriggerFields({ {state.triggerKind === "cron" && ( <>

- {t("office:standardCronExpressionExample")} + {/* + The cron expression is SYNTAX, not copy: it travels as a value so + a translator (and the pseudo-locale) leaves it verbatim. Baked into + the message, reordering a field or localising `MON` yields an + example no cron parser accepts. Same reasoning as + `office:aCronScheduleExample` and `settings:externalMcpEndpointsDescription`. + */} + {t("office:standardCronExpressionExample", { cron: "0 9 * * MON" })}

diff --git a/apps/web/src/locales/en/office.json b/apps/web/src/locales/en/office.json index a26e27209a..b52846cb78 100644 --- a/apps/web/src/locales/en/office.json +++ b/apps/web/src/locales/en/office.json @@ -741,7 +741,7 @@ "sourceType": "Source Type", "spritesRemoteSandbox": "Sprites (remote sandbox)", "staleRunCancelled": "stale run cancelled", - "standardCronExpressionExample": "Standard cron expression (e.g. 0 9 * * MON for every Monday at 9am)", + "standardCronExpressionExample": "Standard cron expression (e.g. {{cron}} for every Monday at 9am)", "startASessionOrSendA": "Start a session or send a message to begin.", "started": "Started", "startFresh": "Start Fresh", diff --git a/apps/web/src/locales/pseudo/office.json b/apps/web/src/locales/pseudo/office.json index 68f4c1ab32..179e5f6a59 100644 --- a/apps/web/src/locales/pseudo/office.json +++ b/apps/web/src/locales/pseudo/office.json @@ -741,7 +741,7 @@ "sourceType": "Śōũŕćē Ţŷƥē", "spritesRemoteSandbox": "Śƥŕĩţēś (ŕēḿōţē śàńďƀōx)", "staleRunCancelled": "śţàĺē ŕũń ćàńćēĺĺēď", - "standardCronExpressionExample": "Śţàńďàŕď ćŕōń ēxƥŕēśśĩōń (ē.ĝ. 0 9 * * ḾŌŃ ƒōŕ ēvēŕŷ Ḿōńďàŷ àţ 9àḿ)", + "standardCronExpressionExample": "Śţàńďàŕď ćŕōń ēxƥŕēśśĩōń (ē.ĝ. {{cron}} ƒōŕ ēvēŕŷ Ḿōńďàŷ àţ 9àḿ)", "startASessionOrSendA": "Śţàŕţ à śēśśĩōń ōŕ śēńď à ḿēśśàĝē ţō ƀēĝĩń.", "started": "Śţàŕţēď", "startFresh": "Śţàŕţ Ƒŕēśĥ",