Skip to content

Commit 30b08b6

Browse files
authored
fix(ci): keep derived locales off the translation worklist (#222)
zh-Hant is generated from its zh-Hans sibling and committed, never translated from English. check-translations.mjs derived its locale list from i18n.ts and treated every non-default locale identically, so --worklist emitted 65 en-to-zh-Hant items -- and TRANSLATION.md calls the worklist the entire input to a pass. DERIVED_FROM moves to .github/scripts/lib/derived-locales.mjs, imported by both translation scripts. The duplicated readers stay duplicated: the re-declaration convention documented over SITE_URL governs a checker versus the thing it checks, and requires the mismatch to be loud. Neither script audits the other, and DERIVED_FROM drift is silent by construction. stale, missing and guide-stale are excluded at one point in survey(), so the worklist and the report columns cannot disagree. unstamped and orphan deliberately still cover derived locales -- those are defects in a file that exists, not work items. --gate=release --require on a derived locale now errors and names the source locale, instead of passing vacuously once the rows are gone. The report renders the derived row as a dash: a zero would read as nothing-to-do, true by accident and false the moment the generator stops being run. Worklist 505 to 440, zh-Hant 65 to 0, no other locale moved. Stale 270 to 222 and Missing 235 to 218 -- exactly the removed rows. The rule is a negative, so every self-test case surveys one fixture tree twice, with DERIVED_FROM and with an empty map, and the second run must emit what the first must not. Closes #216 Refs #221
1 parent d454ccb commit 30b08b6

5 files changed

Lines changed: 374 additions & 21 deletions

File tree

‎.github/scripts/check-translation-output.mjs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import { readFileSync, writeFileSync, readdirSync, existsSync, mkdtempSync, rmSy
101101
import { join, dirname, relative, resolve } from 'node:path';
102102
import { tmpdir } from 'node:os';
103103
import { fileURLToPath } from 'node:url';
104+
import { DERIVED_FROM } from './lib/derived-locales.mjs';
104105

105106
const HERE = dirname(fileURLToPath(import.meta.url));
106107
const ROOT = resolve(HERE, '../..');
@@ -159,9 +160,12 @@ function walk(dir, out = []) {
159160
const localeOf = (f) => LOCALES.find((l) => f.endsWith(`.${l}.mdx`)) ?? null;
160161
const englishOf = (f, l) => `${f.slice(0, -`.${l}.mdx`.length)}.mdx`;
161162

162-
/**
163-
* Locales DERIVED FROM ANOTHER LOCALE rather than translated from English, and
164-
* the locale each one is derived from.
163+
/* ------------------------------------------------------- derived locales --
164+
* `DERIVED_FROM` — which locales are generated from another locale rather than
165+
* translated from English — is imported from `./lib/derived-locales.mjs`, the
166+
* one definition `check-translations.mjs` also reads. That module carries the
167+
* reasoning for why this particular fact is shared while the small readers
168+
* around it stay duplicated. What follows is why it matters HERE.
165169
*
166170
* Every rule below asks "is this file faithful to the thing it was produced
167171
* from?", and until `zh-Hant` shipped that thing was always the English
@@ -188,7 +192,6 @@ const englishOf = (f, l) => `${f.slice(0, -`.${l}.mdx`.length)}.mdx`;
188192
* `unsafe` is untouched by any of this — it needs no sibling, runs over the
189193
* whole corpus, and is the one rule that is never scoped.
190194
*/
191-
const DERIVED_FROM = { 'zh-Hant': 'zh-Hans' };
192195

193196
/**
194197
* The file a locale file must be faithful to: its source-locale sibling for a

0 commit comments

Comments
 (0)