feat(browser): YAML-first translations#48
Merged
Conversation
Translators work in YAML, not JS literals. Built-in i18n table moves from a 557-line TS literal in ui.ts to six per-locale YAML files (src/i18n/strings/<locale>.yaml) parsed at build time via Vite ?raw + the yaml package. Consumer overrides gain a symmetric loadYamlTranslations() helper. API surface unchanged: inline uiStrings literals still work. Consumers who want file-based translations can adopt the new helper without touching existing config. README rewritten to make YAML the primary path. load-translations.spec.ts covers parsing, unicode, escaping, and the freeze guarantee. 183 unit + 51 e2e green.
2 tasks
ronaldtse
added a commit
that referenced
this pull request
Jul 22, 2026
Consumes the changeset from PR #48. Bumps @edoxen/browser 0.9.0 -> 0.10.0 (minor: new public loadYamlTranslations helper + YAML-based built-in locale tables).
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Translators work in YAML, not JS literals. The runtime i18n table now ships as six per-locale YAML files parsed at build time. Consumer overrides gain a symmetric loader.
Added
loadYamlTranslations(yamlString)helper, exported from@edoxen/browser. Parses a YAML mapping of'key': 'value'pairs into a frozenUiStringsrecord. Throws on non-mapping input, ignores non-string values, returns{}for empty input.src/i18n/strings/{eng,fra,zho,spa,ara,rus}.yaml— built-in locale tables extracted from the TS literal that used to live inline inui.ts. Same keys, same values, just YAML. Translators can read these as worked examples.src/i18n/load-translations.spec.ts— six tests covering parsing, unicode/quote escaping, empty input, malformed input, freeze guarantee.Changed
src/i18n/ui.ts—STRINGSconst now referencesBUILTIN_STRINGS(loaded from YAML via?rawimports); the 557-line inline table is gone.loadYamlTranslationsis re-exported for consumers.src/virtual.d.ts— declares*.yaml?rawand*.yml?rawmodules so TypeScript accepts Vite's raw YAML imports.readFileSync+loadYamlTranslations; Option B (inline literals) still works for small overrides. Includes YAML escaping rules ('doubling inside single-quoted scalars, or backslash escapes in double-quoted).Migration notes
No breaking changes — inline
uiStrings: { fra: {...} }literals still work. Consumers who want file-based translations can adopt the new helper without touching existing config. Built-in English + French values are byte-for-byte unchanged.Test plan
pnpm -F @edoxen/browser typecheck— clean.pnpm -F @edoxen/browser test— 183 passed (was 177; +6 new loader spec tests).pnpm -F @edoxen/browser test:e2e— 51 passed.pnpm -F @edoxen/browser build— built-site HTML contains the expected translated strings (Plenary / Resolutions / Meetings).Post-merge
Trigger
release.ymlviaworkflow_dispatchto publish@edoxen/browser@0.10.0(minor — new public helper).