Skip to content

fix(i18n): metadata labels follow language switch without refresh (#1319) - #1391

Merged
os-zhuang merged 1 commit into
mainfrom
fix/expose-canonical-view-shape
May 30, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
fix/expose-canonical-view-shape

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Collaborator

What

Resolves the framework half of #1319: switching the UI language (zh-CN ↔ English) left the app half-translated — static strings flipped instantly but server-resolved metadata labels (object/field/view labels, action-dialog text) stayed in the old language until a hard refresh.

Root cause: metadata labels are resolved server-side and cached per fetch, with no locale awareness in the request or the protocol ETag, so a language switch never refetched them.

Changes

  • @objectstack/client — add setLocale/getLocale; send Accept-Language on every request so the server resolves labels in the active locale.
  • @objectstack/objectql + @objectstack/spec — make the protocol ETag locale-aware so cached metadata no longer collides across languages.
  • @objectstack/client-react — metadata hooks refetch when the active locale changes (ObjectStackLocaleContext, render-phase setLocale sync).
  • @objectstack/rest — honor the request locale when resolving metadata labels.
  • apps/account — thread the router locale through __root.tsx so a language switch relabels in place.

Why this matters

This is the platform half of a two-repo fix. The companion renderer change ships in objectui (createAuthenticatedFetch Accept-Language injection + a render-phase cache clear and key={language} metadata-subtree remount), because objectui consumes @objectstack/client from the registry and can't depend on the unpublished setLocale. Together they satisfy the issue's acceptance criterion: switch language without a page refresh.

Testing

  • packages/client — client.test.ts covers setLocale/getLocale + Accept-Language header.
  • packages/objectql — protocol-meta.test.ts covers the locale-aware ETag.
  • All touched packages type-check clean.

Notes for reviewers

  • This branch was at origin/main; the PR contains a single commit. Unrelated in-progress seed-loader/system-names work in the working tree was deliberately left out.
  • A changeset is included (client/client-react minor; objectql/rest/spec patch).
  • Follow-up milestones from the issue are also done on the objectui side: M2 dev-mode missing-key warnings, M3 date/number/RTL (verified already complete).

#1319)

Server-resolved metadata labels (object/field/view labels, action-dialog
text) were fetched-and-cached per locale and never refetched on a language
switch, leaving the UI half-translated until a hard refresh.

- client: add setLocale/getLocale and send Accept-Language on every request
- objectql/spec: make the protocol ETag locale-aware so cached metadata does
  not collide across languages
- client-react: refetch metadata hooks when the active locale changes
- rest: honor the request locale when resolving metadata labels
- apps/account: thread the router locale so a switch relabels in place

Closes #1319 (framework half; the objectui renderer half ships separately).
@vercel

vercel Bot commented May 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Error Error May 30, 2026 10:37am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels May 30, 2026
@os-zhuang
os-zhuang merged commit 58b450b into main May 30, 2026
10 of 12 checks passed
@xuyushun441-sys

Copy link
Copy Markdown
Collaborator Author

Re: failing Vercel check (spec / apps/docs deployment)

This failure is pre-existing and not caused by this PR — the same Vercel spec docs deployment is currently failing on main (Deployment failed.) and on other open PRs (e.g. #1390). It's an environment/deploy-level breakage independent of these changes.

I reproduced the docs build's spec-generation steps locally against this branch:

pnpm --filter @objectstack/spec gen:schema   # ✅ 1684 schemas generated
pnpm --filter @objectstack/spec gen:docs     # ✅ Done!

Both pass. The only spec change here is one optional locale field on GetMetaItemCachedRequestSchema, which flows through schema/doc generation cleanly. No code change is warranted for this check; it should go green once the docs deployment is fixed on main.

This branch had an error being deployed

1 failed deployment
Preview — 9be3198d Deployed May 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants