Repository navigation
Commit 692e0dc
fix(showcase): translate the task detail review banner under zh-CN (#29104)
<!-- claude-projects-attribution: {"github_login":"marchtian"} -->
_Requested by **田騏** · [project
thread](https://claude.ai/code/project/chan_01VmuUhXU9SSUzqJYyXSmYSi?thread=cmsg_01VmuUhXU9SSUzqJYyXSmYSi9paTx1Lu8ENYwwssthfK3h)_
Fixes #28982
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:showcase 任务详情页顶部的「待评审」黄色提示条在中文会话下改为中文——标题走翻译包,正文用页面上的内联多语言文本。
- 为什么改:中文用户打开评审中的任务,整页都是中文,唯独这条提示是英文,像没翻完;发版清单
i18n.notification-localized-and-clears 的 A1(不得中英混排)因此一直红。
- 风险与回滚:只动示例应用,不发布任何包;提示条的「关闭记忆」改用固定键,之前关掉过它的人会再看到一次;回滚即还原本 PR。
-
先看:`examples/app-showcase/src/ui/pages/task-detail.page.ts`(record:alert
节点的 id、body、dismissKey)→
`examples/app-showcase/src/system/translations/index.ts`(zh-CN 的
pages.showcase_task_detail)→ 新测试文件。
- 两分钟验证:`pnpm --filter @objectstack/example-showcase exec vitest run
test/task-detail-review-alert-zh-cn.test.ts`,预期 3
passed;或中文会话打开种子任务「Design system」,提示条显示「待评审」和中文正文。
- 需要你做的:无,席位落地。
## What changes
The Task Detail page (`showcase_task_detail`) shows a `record:alert`
banner while a task is in review. On a zh-CN session it rendered in
English because the node had no component `id`, and page component copy
is translated through `pages.NAME.components.COMPONENT_ID.KEY`.
- `task-detail.page.ts`: the banner gets `id: 'review_alert'`
(snake_case, like the page ids elsewhere in the showcase:
`new_project_form`, `project_picker`).
- `translations/index.ts`: the zh-CN bundle gains
`pages.showcase_task_detail.components.review_alert.title` = 待评审. The
`en` block carries no `pages` entries, and the authored English stays
the default text. The showcase ships `en` and `zh-CN` only
(`objectstack.config.ts` `supportedLocales`), so no other locale needs
the key.
- **`body` does not go through the bundle, because the bundle has no key
for it.** The page-component copy face is `title / description / label /
placeholder / emptyText` (`PAGE_COMPONENT_COPY_KEYS`,
`packages/spec/src/system/i18n-resolver.ts`), and the bundle schema is
strict there. Measured on the built spec: an entry with only `title`
parses, and one with `title` plus `body` is refused with
`unrecognized_keys` ("Unrecognized key(s) on this page component
translation: `body`"). `RecordAlertProps.body` is declared
`I18nLabelSchema`, and the renderer reads it through `pickLocalized`, so
the body is now an inline locale map holding both `en` and `zh-CN`. This
follows the recorded precedent for `element:text` `content` in
`translation.zod.ts`: the inline locale map is the ruled route for page
prose, and that shape was not added to the bundle.
- `dismissKey: 'showcase_task_review'`: the dismissal key defaults to
the English resolution of `title`. Once the bundle translates the title,
a zh-CN session would resolve that key to the translation, so a banner
dismissed in one locale would come back in the other. The key is now
fixed.
## Tests
- New pin:
`examples/app-showcase/test/task-detail-review-alert-zh-cn.test.ts`. It
applies `translateMetadataDocument('page', …)` to the page with the
app's own bundle, which is the same thing the REST boundary does for
each request locale. It asserts the zh-CN title, that the body's locale
map comes back intact, the fixed `dismissKey`, the English title under
`en`, and that the zh-CN bundle still parses under
`TranslationBundleSchema`. Its model is
`zh-cn-report-blocks-inline-titles.test.ts`.
- Reverse check, run once: with the two source files restored to base
`ab085a0482` and the test kept, the pin goes red (`expected undefined to
be 'review_alert'`, 1 failed and 2 passed). Restored from `HEAD`, `git
diff HEAD` is empty.
## Acceptance notes
- The card listed `title/body` under the bundle key. Only `title` can go
there (see above). Adding `body` to the page-component face would widen
the spec (`Metadata-protocol: added`), and the `content` precedent
declined that for prose of the same shape. This PR stays inside the
current contract.
- The inline locale map on `body` cannot be seen by `os i18n extract` or
`check:i18n-coverage`. That extractor question is a known one and is out
of scope here.
- Read-only survey of the showcase pages, not fixed here and not
measured in a browser: these id-less components carry copy on the bundle
face, so they have no zh-CN key. `showcase_my_work`: the `object-metric`
label and description ("Open Tasks", "In Review", "At-Risk Projects")
and the `page:card` titles "Shortcuts" and "Leadership View".
`showcase_component_gallery`: four `object-metric` blocks and an
`element:button` "Create Task". `showcase_project_detail`: the
`record:line_items` and `record:related_list` titles "Tasks". Several
`element:text` `content` strings on those pages are plain English. Their
route is the inline map, not the bundle.
## Verification
Head `6c6289c0c9` (`origin/main` merged once, at `c708de67b2`). The
dependency closure was rebuilt after the merge.
<details><summary>Showcase package: typecheck, tests, validate</summary>
- `pnpm --filter @objectstack/example-showcase typecheck && … exec
vitest run --maxWorkers=2` (run under the verify lock): `VERDICT
command-exit 0`, Test Files 43 passed (43), Tests 514 passed (514)
- `pnpm --filter @objectstack/example-showcase validate`: exit 0. No
finding names `showcase_task_detail` or the banner.
</details>
<details><summary>Derived gates (dispatch-gates --commands,
40)</summary>
- 39 gates exited 0, including `check:i18n-coverage` ("OK (14 config(s),
426 baselined untranslated string(s), none new)"),
`check:page-declaration-shape`, `check:nul-bytes` and
`check:examples-live-imports`.
- `check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET). It needs
dist output from packages outside this diff's closure, so it is NOT
MEASURED here and is left to CI.
- `--ran` reconciliation: "40 derived famil(ies) accounted for — 39 run,
1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".
</details>
Changeset: none. `@objectstack/example-showcase` is `private: true` and
publishes nothing, so the PR carries `skip-changeset`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude <noreply@anthropic.com>1 parent 93153f0 commit 692e0dc
3 files changed
Lines changed: 88 additions & 1 deletion
File tree
- examples/app-showcase
- src
- system/translations
- ui/pages
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1243 | 1243 | | |
1244 | 1244 | | |
1245 | 1245 | | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1246 | 1254 | | |
1247 | 1255 | | |
1248 | 1256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
94 | 109 | | |
| 110 | + | |
95 | 111 | | |
96 | 112 | | |
97 | 113 | | |
98 | 114 | | |
99 | 115 | | |
100 | 116 | | |
101 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
102 | 121 | | |
| 122 | + | |
103 | 123 | | |
104 | 124 | | |
105 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
0 commit comments