Skip to content

i18n: language registry — a locales/ directory is a language or a build error - #801

Merged
GLinnik21 merged 15 commits into
mainfrom
i18n/language-registry
Oct 16, 2026
Merged

GLinnik21 merged 15 commits into
mainfrom
i18n/language-registry

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What

A data-driven language registry for the catalog compiler. locales/languages.json declares every UI language; the platform build script discovers locales/*/, refuses any directory that is not registered (and any registration without a directory), and generates Preference, Language and their tables into OUT_DIR/languages.rs.

Why

#771 merged green but dead: catalog::build read four hard-coded directories and nothing else, so locales/it/ was never compiled. Adding Italian then took 25 files in #783. Now a new language is a catalog directory, one registry line and pkg/resources/<tag>/appinfo.json: 0 Rust files.

How

  • Registry (locales/languages.json): tag, native name, region, script, CLDR plurals, Settings row. Validated in the build (tag shape, reserved tags, renderer scripts, unique rows 1..999, English present).
  • Discovery errors (platform/build_support/catalog.rs): unregistered directory, registered-but-missing directory, stray files, non-JSON files in a locale, wrapped {"value","description","args"} translations (Add Italian localization (it) #771's mistake), missing/extra keys, missing or never-selected plural forms. Errors are collected, sorted, prefixed <tag>/<file>: <key>: and capped per language. compile(source, langs) -> Result<Generated, Vec<String>> plus check_keys(lang, &expected) is the seam the English-only ("translate": false) follow-up plugs into.
  • Generated enums: i18n/mod.rs keeps only behavior; Preference/Language, from_tag, tag, native_name, settings_row, regional, parse, saved-slot mapping and SHIPPED come from the registry. Persisted values are the tag strings, unchanged. Settings' Language page is System + SHIPPED; Contribute moves to row 1000.
  • SHIPPED loops: the hand-listed "every language" loops (appkit, plex, screens, ui, diagnostics) now iterate i18n::SHIPPED, including login.rs's off-canvas check that silently omitted French. preferences_text_fit_tests no longer falls back to Belarusian with _ =>.
  • ICU plural test: declared plurals must equal ICU's PluralRules::categories(), and decimal/plural data must be the language's own, not root's.
  • ci/check-language-lists.py (+ unit test, counted allowlist ci/allow/language-lists.txt of the 5 pinned-translation files), run from ci/check-python-steps.txt.
  • Docs: docs/localization.md "Adding a language", ui/src/CLAUDE.md, module-layers.md; SCREEN_SHAPES string left as is with a "never generate from the registry" comment.

Verification

Regression test an_unread_locale_directory_is_an_error written before the registry code, run against the unchanged build() (temp locales/ with en/es/be/fr/it plus an unregistered xx/):

test i18n::catalog_tests::tests::an_unread_locale_directory_is_an_error ... FAILED
a locales/xx directory nothing reads must fail the build
test result: FAILED. 6 passed; 1 failed

Green after the registry: make test-crate C=plx_platform T=i18n 19 passed (23 with the ICU/compat tests); plx_screens language, readouts, consent, preferences, item_menu, collection, person, plaintext; plx_appkit capsule, hud; plx_ui route_screen, text_view; plx_plex pms_headers; cargo +nightly check --workspace --lib --tests and --lib --no-default-features clean; ci/test_check_language_lists.py, ci/test_ci_split.py, ci/check-deps.sh, ci/check-module-layers.py green.

Known: plx_appkit track_menu::style_page_tests::the_style_note_fits_two_lines_at_the_player_menu_floor fails for Italian ("It pgs: the note takes 4 lines at 440px") on the #795 base too; this PR does not touch that test.

Full gates: CI on this draft.

Stacked on #795.

🤖 Generated with Claude Code

esolitos and others added 10 commits October 15, 2026 23:00
Translate all 1,000 catalog messages with context-aware Italian copy, wire Italian into locale selection and message generation, and extend per-language fit and locale tests. Shorten strings identified by host text-fit checks while retaining the complete consent disclosures.
Adds the five settings.playback.hdr_overlay strings main gained after #783 was cut.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from land/pr-783 to main October 16, 2026 12:30
@GLinnik21
GLinnik21 marked this pull request as ready for review October 16, 2026 12:43
@GLinnik21
GLinnik21 merged commit 646859f into main Oct 16, 2026
19 checks passed
@GLinnik21
GLinnik21 deleted the i18n/language-registry branch October 16, 2026 12:43
GLinnik21 added a commit to tiper/fin-native that referenced this pull request Oct 16, 2026
main gained a data-driven language registry (plxnative#801) and English-only
technical strings (plxnative#806), so the language needs no Rust wiring now: the
catalogs move to locales/pt/ with one locales/languages.json row (region
pt-PT, excluded_regions ["BR"] so pt-BR keeps the English fallback), and
the hand-wired Rust changes from this branch are superseded by main's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants