Skip to main content

Module catalog

Module catalog 

Source
Expand description

The zh and en diagnostic and progress messages, and the formatter that fills in their {{name}} placeholders; also the display names of regions and canvases (display_name()).

The catalogues are the diag, progress and names sections of src/i18n/{zh,en}, exported to catalog/*.json by scripts/export-catalog.ts (deno task export-catalog); tests/unit/catalog-export.test.ts fails when the checked-in JSON no longer matches the TypeScript. format() reproduces what the page’s t() (i18next 26 with escapeValue: false) returns for the same key and values, so a diagnostic formatted natively reads exactly like the one the page persists. The export refuses catalogue features this formatter does not implement (nesting, formatters, unescaped placeholders, plural keys), so the two cannot drift apart silently.

Enums§

Locale
A catalogue language. zh is the language persisted rows are written in and the fallback for a missing en key.
Param
One interpolation value, rendered the way JavaScript’s String(value) renders it.

Functions§

display_name
A region or canvas name in locale, for display. Persisted names are a fixed zh vocabulary (names in the catalogue: 固定界面, 内容画布 N, …) whatever the display language, so rows and fingerprints do not depend on it; this translates one the way the page’s displayName (src/i18n/names.ts) does: the base name, then an optional · 未定位片段 N (unplaced fragment) suffix, then an optional · 保留外框 (framed) suffix, each on its own. A name outside the vocabulary is kept as stored, and zh returns every name unchanged.
format
The message for key in locale with params filled in, exactly as the page’s t(key, params) would return it: an en key that is missing falls back to zh, a key that is missing everywhere comes back as the key itself, and a placeholder whose name is not among params stays in the text as written.
js_number
JavaScript’s Number.prototype.toString() (radix 10): shortest round-trip digits, plain notation for exponents in [-7, 21), exponent notation (1e+21, 1e-7) outside it, -0 as 0.
lookup
The text stored under a dotted key (e.g. diag.GRAPH_RESIDUAL.message), without falling back to zh.