Skip to content

RFC: Host locale subscription - #526

Open
kalininilya wants to merge 2 commits into
mainfrom
feat/locale-subscribe
Open

RFC: Host locale subscription#526
kalininilya wants to merge 2 commits into
mainfrom
feat/locale-subscribe

Conversation

@kalininilya

Copy link
Copy Markdown

RFC + protocol implementation for a host locale subscription.

locale.subscribe() pushes the language the host presents its interface in, as a BCP 47 tag, on subscribe and on every change. A product renders in that language instead of inferring one from navigator.language, which reports the operating system's preference and is wrong whenever the user picked a different language inside the host.

The RFC and the crate change travel together because check-rfc.yml fails any PR touching docs/rfcs/** that does not also change rust/crates/truapi/.

Shape

struct HostLocaleSubscribeItem {
    /// BCP 47 language tag.
    pub language_tag: String,
}

Wire ids 194–197. LocaleHost joins the required Platform set alongside ThemeHost, so a host serves a real value rather than reporting the method unsupported.

The tag is an open string rather than an enum of shipped languages: a host adds a language without a protocol change, and a product that ships no catalog entry for the tag it receives picks its own fallback.

Verified

  • cargo test --workspace — 1052 passed, 0 failed
  • cargo +nightly fmt --check and cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • ./scripts/codegen.sh regenerated the client, dispatcher, wire table and WASM bridge; golden diffs are locale-only
  • js/packages/truapi: npm run build and npm test — 255 passed

Tracking issue follows.

Products receive the language the host presents its interface in, as a
BCP 47 tag pushed on subscribe and on every change.

Wire ids 194-197. LocaleHost joins the required Platform set.
Swift and Kotlin bridges default currentLocale() to the system language,
so an existing host keeps compiling without implementing it.
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.

1 participant