fix(i18n): metadata labels follow language switch without refresh (#1319)#1391
Merged
Conversation
#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).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Author
Re: failing Vercel check (
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— addsetLocale/getLocale; sendAccept-Languageon 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-phasesetLocalesync).@objectstack/rest— honor the request locale when resolving metadata labels.apps/account— thread the router locale through__root.tsxso 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 (
createAuthenticatedFetchAccept-Language injection + a render-phase cache clear andkey={language}metadata-subtree remount), because objectui consumes@objectstack/clientfrom the registry and can't depend on the unpublishedsetLocale. Together they satisfy the issue's acceptance criterion: switch language without a page refresh.Testing
packages/client—client.test.tscoverssetLocale/getLocale+Accept-Languageheader.packages/objectql—protocol-meta.test.tscovers the locale-aware ETag.Notes for reviewers
origin/main; the PR contains a single commit. Unrelated in-progress seed-loader/system-names work in the working tree was deliberately left out.client/client-reactminor;objectql/rest/specpatch).