Wire rust-i18n locale preference contract for panel i18n #274
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#274
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Wire
rust-i18ninto the server/shared crates and expose a locale preference, per plan/shared/internationalisation.md (ADR 0013). This blocks #38, which needs a contract to build the panel's language switcher against.Checked and confirmed missing (2026-11-16): no
rust-i18ndependency anywhere in the workspace, nolocales/directory, no bundle files, no locale field onUserView/SessionUser, no locale-preference endpoint, no server-default-locale config.Proposed contract (for agreement, not dictation — change it where it doesn't fit)
crates/shared/locales/{en,nl}.yml, loaded viarust_i18n::i18n!("locales")in thesharedcrate so bothserverandclientbinaries can translate messages. Key naming: dot-path, e.g.panel.nav.devices.en.ymlis a build error; a missing key innl.yml(or any later locale) is a warning only; a stale key present in a translation but absent fromen.ymlis a build error. (Already specified in the plan doc, just needs the check implemented — Helpdesk has the same split if there's a pattern worth reusing.)default_locale, env overrideDEFAULT_LOCALE), defaulting toenif unset. Per GRI-1884 / the no-hardcoding rule, this must not be a literal in code.locale: stringtoUserView(returned byGET /session,POST /session,/setup), defaulting to the server default for a user who hasn't chosen one.PATCH /session/localeor folded into whatever the "update my profile" endpoint turns out to be (none exists yet either, as far as I could find) — backend engineer's call.enwith nothing configured), per the plan doc's "client messages" section.Done when
rust-i18nis wired intoshared, withenandnlbundles (even ifnlonly covers a handful of strings at first — "a contributor who adds half a language has helped").UserViewcarrieslocale, settable via an endpoint, with a documented contract (OpenAPI/types or a doc comment on the response type) that the frontend can code against.build.rscheck.Depends on
ADR 0013 (closed, #37).
Blocks
#38 (panel language switching — frontend, Glamourweaver).
Implemented and pushed: PR #276 (
feature/GRI-2142-i18n-locale-contract→dev).Wired:
rust-i18ninshared(bundles:crates/shared/locales/{en,nl}.yml) andserver(each crate needs its owni18n!invocation —t!always expands tocrate::_rust_i18n_t!, so a re-export of the macro alone would not reach another crate's bundles).crates/shared/build.rsenforces the three key-check outcomes from the plan doc on every build (not a manually-runcargo i18n): missing-in-English fails, missing-in-translation warns, stale-in-translation fails. Verified all three by hand (temporarily broke each one, confirmed the right failure, reverted).config.i18n.default_locale(envSIGNAGE_I18N_DEFAULT_LOCALE), refused at load for an unshipped locale.users.locale(migration0011, nullable = "use the server default").UserView.localeon/setup,/session(GET/POST);PATCH /session/localesets it,400 unknown_localeotherwise.Deviation worth flagging: ADR 0013 says to lean on rust-i18n's own tooling for the key checks rather than a bespoke one. I did that for bundle loading, but deliberately not via
rust-i18n-extract(the library behindcargo i18n's own extractor) for the "used in code" scan — itsCargo.tomlunconditionally depends onserde_yaml, which pulls inunsafe-libyaml(RUSTSEC-2024-0449, unmaintained, no safe upgrade), and this project'scargo denygate correctly refuses that.build.rs's scan is a small hand-rolled literal-argument scanner instead (same shape as Helpdesk's owntk!scanner), with no new advisory surface. The bundle loader used for the other two checks is unaffected — it parses YAML withserde-saphyr, notserde_yaml.Not wired: the client's own message screens (pending-registration, key-mismatch, etc.) — none of them call
t!()yet, so there's nothing on that side for this issue to wire up. Left for whichever issue converts the first one.All local gates green:
cargo fmt,cargo clippy -D warnings,cargo test --workspace --all-targets(incl. a newsession_locale_integration.rs, run against a real Postgres — 30/30 binaries),cargo test --doc,cargo deny check -D advisory-not-detected.CI is queued on the PR (
fj ci 276), ETA ~1h20m per the queue drain rate at the time of this comment.CI is green on PR #276 (#276), commit
4ed1a001: clippy, fmt, cargo deny + advisories, cargo test (incl. new session_locale_integration.rs against real Postgres), frontend-web, repository boundary, pre-push hook all passing. Handing off to the CTO for code review and merge into dev.