feat(design): the Copy rule — names, verbs, dates and units (E28 S3g)

The owner's picks (all the recommended options) become DESIGN.md's Copy
chapter and a sweep of both languages (742 values, no key drift):

- One name per feature: the rail's label, which may shorten it (Alerts
  -> Notifications, Fiókok -> Felhasználók, Download Center -> Downloads,
  Channel manager -> Channels); one "sync from YouTube" verb.
- Four verbs, four meanings (Delete / Remove / Dismiss / Discard, and
  their Hungarian pairs), checked against what each action does.
- Sentence case, the app's places capitalised; "…" on a command that
  asks first (a popover or form title got its own key without it);
  one-sentence messages without a stop or a tick, "Couldn't …"; curly
  quotes.
- Dates only from lib/format.ts, in the UI language: formatDateTime
  names the month and stops at the minute (it printed "9/27/2026,
  8:30:14 AM"), formatDateTimeSec for the log, the audit and the
  recorder; ui/RelativeTime pairs "3d ago" with the exact minute on
  hover. local/date-format refuses toLocale*String and Intl date
  formatters elsewhere.
- Units from Intl, short (formatUnit): runtimes, totals, the Scheduler
  countdown, the stats range, the player's tap skip. "2h 13m" was
  English in both languages.
- src/i18n/copyRule.test.ts holds the machine-readable part (quotes,
  "...", ticks, bare unit letters).
This commit is contained in:
2026-09-27 05:46:17 +02:00
parent 2c65edfffd
commit bd6aaa1e43
100 changed files with 1193 additions and 964 deletions
+45
View File
@@ -0,0 +1,45 @@
import { describe, expect, it } from "vitest";
// docs/DESIGN.md "Copy" (E28 S3g): the parts of the copy rule a machine can read, held over every
// value in both languages. The rest (one name per feature, one verb per meaning, "…" when a command
// asks first) needs a reader and is checked by the DESIGN conformance step.
const files = import.meta.glob("./locales/*/*.json", { eager: true, import: "default" }) as Record<
string,
unknown
>;
function values(): [string, string][] {
const out: [string, string][] = [];
const walk = (o: unknown, path: string) => {
if (typeof o === "string") out.push([path, o]);
else if (o && typeof o === "object")
for (const [k, v] of Object.entries(o)) walk(v, path ? `${path}.${k}` : k);
};
for (const [file, json] of Object.entries(files))
walk(json, file.replace("./locales/", "").replace(".json", ":"));
return out;
}
const offenders = (test: (v: string) => boolean) =>
values()
.filter(([, v]) => test(v))
.map(([k, v]) => `${k} = ${v}`);
describe("the copy rule", () => {
it("quotes a name with curly quotes, never straight ones", () => {
expect(offenders((v) => v.includes('"'))).toEqual([]);
});
it("writes an ellipsis as one character", () => {
expect(offenders((v) => v.includes("..."))).toEqual([]);
});
it("ends no message with a tick", () => {
expect(offenders((v) => v.includes("✓"))).toEqual([]);
});
it("spells no unit as a bare letter after a number ('90m', '24h', '{{count}}d', '10 s')", () => {
expect(offenders((v) => /(\d|\}\})\s?(m|h|d|s)(?![\p{L}\d/])/u.test(v))).toEqual([]);
});
});