Skip to content

Commit 2283cd9

Browse files
committed
refactor(field-labels): read the label languages off the spec instead of mirroring them by hand
The list carried a comment saying it mirrors the locale files, which is the shape that goes stale: an eighth language would generate no labels and raise nothing, so its fields would render in English with every gate green. The spec lang enum already decides the set, and the locale suite is already checked against it. Same seven languages, byte-identical output.
1 parent f44169f commit 2283cd9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

scripts/sync-field-labels.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,20 @@
2424
*/
2525
import { existsSync } from 'node:fs';
2626
import { mkdir, writeFile } from 'node:fs/promises';
27+
import { API_LANGUAGES } from '../packages/ui/src/generated/api-languages.js';
2728

2829
const API_BASE = process.env.ROXY_API_BASE ?? 'https://roxyapi.com/api/v2';
2930
const OUT_DIR = 'packages/ui/src/locales/field-labels';
3031

31-
/** Mirrors the locale files that exist; English is deliberately absent (it needs no payload). */
32-
const LANGS = ['de', 'es', 'fr', 'hi', 'pt', 'ru', 'tr'] as const;
32+
/**
33+
* Derived from the spec, never mirrored by hand. English is absent because it needs no payload.
34+
*
35+
* @remarks
36+
* A hand-kept copy is checked against itself, and the language somebody forgets to add to it is
37+
* the one that then ships with unlabelled fields and no error anywhere (lesson 23). `lang` on the
38+
* spec is the only place the set is decided, so read it from there.
39+
*/
40+
const LANGS = API_LANGUAGES.filter((l) => l !== 'en');
3341

3442
interface LabelPayload {
3543
fields?: Record<string, string>;

0 commit comments

Comments
 (0)