fix(i18n): pass the routine cron example through as a value (#2373)

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
João Salavisa
2026-08-07 17:24:56 +02:00
committed by GitHub
parent 5e3af8e839
commit 28f6a1fd25
4 changed files with 49 additions and 3 deletions
@@ -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)",
);
});
});
@@ -224,7 +224,14 @@ function TriggerFields({
{state.triggerKind === "cron" && (
<>
<p className="text-xs text-muted-foreground -mt-2">
{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" })}
</p>
<div>
<Label htmlFor="routine-timezone">{t("office:timezone")}</Label>
+1 -1
View File
@@ -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",
+1 -1
View File
@@ -741,7 +741,7 @@
"sourceType": "Śōũŕćē Ţŷƥē",
"spritesRemoteSandbox": "Śƥŕĩţēś (ŕēḿōţē śàńďƀōx)",
"staleRunCancelled": "śţàĺē ŕũń ćàńćēĺĺēď",
"standardCronExpressionExample": "Śţàńďàŕď ćŕōń ēxƥŕēśśĩōń (ē.ĝ. 0 9 * * ḾŌŃ ƒōŕ ēvēŕŷ Ḿōńďàŷ àţ 9àḿ)",
"standardCronExpressionExample": "Śţàńďàŕď ćŕōń ēxƥŕēśśĩōń (ē.ĝ. {{cron}} ƒōŕ ēvēŕŷ Ḿōńďàŷ àţ 9àḿ)",
"startASessionOrSendA": "Śţàŕţ à śēśśĩōń ōŕ śēńď à ḿēśśàĝē ţō ƀēĝĩń.",
"started": "Śţàŕţēď",
"startFresh": "Śţàŕţ Ƒŕēśĥ",