Skip to content

feat(host): add getLocaleProvider for the host's selected language - #333

Merged
valentinfernandez1 merged 3 commits into
mainfrom
feat/locale-subscribe
Aug 31, 2026
Merged

feat(host): add getLocaleProvider for the host's selected language#333
valentinfernandez1 merged 3 commits into
mainfrom
feat/locale-subscribe

Conversation

@kalininilya

Copy link
Copy Markdown
Contributor

Adds getLocaleProvider, so a product renders in the language the user picked inside the host rather than inferring one from navigator.language — which reports the operating system's preference and is wrong whenever the two differ.

import { getLocaleProvider } from "@parity/product-sdk-host";

const provider = await getLocaleProvider();
const sub = provider?.subscribeLocale((locale) => {
  i18n.activate(SUPPORTED.has(locale.languageTag) ? locale.languageTag : "en");
});

subscribeLocale fires with the current locale and again on every change; the returned HostSubscription carries unsubscribe and onInterrupt. getLocaleProvider resolves to null outside a host container.

languageTag is a BCP 47 tag such as "en", "pt-BR" or "zh-Hans". The set is open — a host adds languages without an SDK release — so a product that ships no catalog entry for the tag it receives picks its own fallback.

The fake client models locale as not-modeled, so a test that reaches for it fails loudly rather than silently returning nothing.

Protocol counterpart: paritytech/host-rust-core#526.

Blocked on

A @parity/truapi release carrying the locale domain. The catalog pins ^0.10.0, which predates it, so CI will not go green until that lands.

Verified

  • pnpm --filter @parity/product-sdk-host typecheck against a local @parity/truapi built from RFC: Host locale subscription host-rust-core#526 — no locale errors. One unrelated error remains (system.info / getProductContext missing from the fake client), which reproduces on a clean tree with the same link: it is drift between host-rust-core main and the published 0.10.0, not this change.
  • pnpm --filter @parity/product-sdk-host test — 20 files, 123 tests passed, including the new in-source locale.ts test.

@duewarn

duewarn commented Aug 31, 2026

Copy link
Copy Markdown

Hey @valentinfernandez1 @decrypto21 @TarikGul @pgherveou ! As paritytech/host-rust-core#526 has been approved and merged, could you take a look at the implementation for the Product SDK? This functionality is included in the first release for mobile apps and the Funding modality.

@duewarn
duewarn requested review from TarikGul and pgherveou August 31, 2026 09:47
@valentinfernandez1

valentinfernandez1 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Hi @kalininilya will take a look. There are some failing checks that you need to resolve. <

Also, how urgent is this? to know whether we need to create a truapi release asap to include the pr from host-rust-core or if it can wait till it lands alongide the next release.

@valentinfernandez1 valentinfernandez1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, blocking until truapi release and fix on the changeset are fixed

Comment thread product-sdk/pending-changesets/host-locale-provider.md
Comment thread product-sdk/packages/host/src/locale.ts
@duewarn

duewarn commented Aug 31, 2026

Copy link
Copy Markdown

@valentinfernandez1 thank you for review! These changes have not yet been merged on the hosts - this is expected to happen today or tomorrow. However, as soon as you release the new version of the Product SDK, it will be possible to integrate the new subscription into GetCash (Funding modality), which is included in the scope of the first release on 4 September.

@valentinfernandez1

Copy link
Copy Markdown
Collaborator

Ok I will do a release on truapi first so we can integrate this change.

@valentinfernandez1

Copy link
Copy Markdown
Collaborator

Truapi release done, bumped by #353. I'm also bumping truapi on dotli with #189 side so this should be available there on the next dotli release too.

kalininilya and others added 3 commits August 31, 2026 17:58
Products render in the language chosen inside the host instead of
inferring one from navigator.language, which reports the operating
system's preference.

Backed by truApi.locale.subscribe; needs a @parity/truapi release
carrying the locale domain.
Co-authored-by: Valentin Fernandez <33705477+valentinfernandez1@users.noreply.github.com>
#353 landed the catalog bump on main, along with the `locale` entry in the
testing fake this branch also carried — the rebase kept both copies. Drop
ours and let main's stand, leaving this branch to `getLocaleProvider` alone.

The changeset loses its blocker line for the same reason: the truapi release
it waited on is the one already on the catalog.

Claude-Session: https://claude.ai/code/session_012eRddy3YXhy5x3WzCpYYka
@kalininilya
kalininilya force-pushed the feat/locale-subscribe branch from 30e1673 to d6ac566 Compare August 31, 2026 16:01
@github-actions

Copy link
Copy Markdown

📦 Bundle size impact

Comparing 2026-08-31T16:06:14.859Z2026-08-31T16:05:56.393Z

Package Entry Bundled before Bundled after Δ Ship gzip Δ Shake ratio
🟢 @parity/product-sdk ./host 98.1 KB 98.3 KB +159 B (+0.2%) 0 B 8% (was 8%)
🟢 @parity/product-sdk-host . 98.1 KB 98.3 KB +159 B (+0.2%) +36 B 8% (was 8%)
🟢 @parity/product-sdk-statement-store . 109.8 KB 110.0 KB +159 B (+0.1%) 0 B 9% (was 9%)

Thresholds — 🟡 ≥10% or ≥5.0 KB · 🟠 ≥20% or ≥15.0 KB (bundled). Percentage only applies once the baseline is ≥ 10 KB. Informational — this check never blocks merge.

@valentinfernandez1
valentinfernandez1 merged commit 8bb2ddc into main Aug 31, 2026
14 of 15 checks passed
valentinfernandez1 pushed a commit that referenced this pull request Sep 1, 2026
Move the seven changesets for work merged to main since 0.25.0 from
pending-changesets/ into .changeset/ so the release runs:
locale provider (#333), individuality registration/fromPapi (#341),
txExtVersion from formats (#342), candidate progress (#343),
localStorage.clear removal (#345), airdrop id decode (#346), truapi 0.12.0 (#353).

Bumps: host + individuality + umbrella minor, terminal and the rest patch.
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.

3 participants