You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 758bbe7
Browse filesBrowse the repository at this point in the historyBrowse files
feat(spec,lint,i18n): translation bundle key for an action answer table's column headers (#34915)
Fixes#34652
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB5Q5XDchqCqfEmNMpqTSQr1)_
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #34917
## 维护者速读
- 改了什么:动作结果弹窗和预检面板里「表格」的列标题现在有翻译键
`resultDialog.columns.字段路径.列路径`(预检同理),与 `fields`
并列;抽取、校验、服务端翻译和控制台叠加都按这个键走,平台包里「导入用户」结果表的 9 个列标题已译成全部 10 种语言。
- 为什么改:PR #34647 让结果弹窗能画表格,但列标题没有翻译键,中文等语言界面下表头一直是英文。
- 风险与回滚:只加不减。旧翻译包一字不改照样通过、照样显示;没有列键时列标题保持作者原文。回滚即撤销本 PR。
- 先看:`packages/spec/src/system/translation.zod.ts`(新的 `columns`
形状)、`packages/spec/src/system/i18n-resolver.ts`(`overlayAnswerColumnLabels`)、`ui/packages/i18n/src/useObjectLabel.ts`(控制台叠加)。
- 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run
src/system/i18n-resolver.test.ts -t "answer table column labels"`,预期 7
条全绿。
- 需要你做的:无,席位落地。
## What changes
**The key, and why it is a sibling map.**
`ActionResultDialogTranslationSchema` and the module-local
`ActionPreflightTranslationSchema` each gain an optional `columns`:
`Record<fieldPath, Record<columnPath, string>>`, both keys the LITERAL
paths from the action metadata (dots included, indexed directly, never
split). The bundle reads
```ts
resultDialog: {
fields: { rows: '逐行结果' },
columns: { rows: { email: '邮箱', 'error.message': '未添加的原因' } },
}
```
The card suggested nesting the column map under the field entry
(`fields.PATH.columns.COL`). I chose the sibling map instead: a
`fields.PATH` value stays the field's label string, so no existing
bundle, generated file or resolver ever sees a field entry that is
sometimes a string and sometimes an object; every bundle that parses
today parses unchanged and reads the same, and nothing about a table
field's own label key moves. The shared shape is one module-local
`ActionAnswerColumnLabelsSchema` (no new export, so the published
skills' reference indexes do not move).
**Threaded through.**
- `packages/spec/src/system/i18n-resolver.ts`:
`resolveActionResultDialog` and `resolveActionPreflight` (so
`translateAction` and every served object) overlay each declared
column's `label` from the bundle through the locale chain; a column with
no key keeps its authored label, a field with no `columns` is the same
reference. `ResultDialogLike` / `PreflightLike` rows gain an optional
typed `columns`.
- `packages/lint/src/i18n-walk.ts`: `pushAnswerTableColumns` emits
`…resultDialog.columns.PATH.COL` and `…preflight.columns.PATH.COL` for
every labelled column (an unlabelled column draws its path and gets no
key, as an unlabelled field row gets none), so `os i18n extract` and the
coverage gate list them.
- `packages/lint/src/validate-translation-references.ts`:
`checkActionAnswerTableColumns` refuses (`translation-target-unknown`,
error) a `columns` key naming a field that is not a declared `format:
'table'` field with `columns`, a column path its `columns` does not
list, or a block the action does not declare; the coverage pin
classifies both new keys as reference-checked with a ghost leg at both
addresses. `rule-explanations.ts` names the two keys.
- `ui/packages/i18n/src/useObjectLabel.ts`: `actionResultDialog` and
`actionPreflight` read the `columns` node whole (`returnObjects`) and
overlay declared columns only. `ActionResultDialog.tsx`'s `TableBlock`
already draws `resolveInlineI18nLabel(column.label)` from the overlaid
rows, so it is unchanged.
- `packages/platform-objects/src/apps/translations/*`: regenerated with
`node scripts/check-i18n-bundles.mjs --write`;
`sys_user.import_sso_users`'s nine result-table headers are translated
by hand in zh-CN, zh-Hant, ja-JP, ko, es-ES, pt-BR, fr, de, ru and ar
(no source-hash echo rows remain).
- Docs: `content/docs/references/system/translation.mdx` (regenerated),
`content/docs/protocol/kernel/i18n-standard.mdx` (the resolvable-key
table), `content/docs/ui/translations.mdx` (the key table and the
result-dialog callout).
**Measured on the surface.**
`packages/spec/authorable-surface/system.json` gains one row,
`system/ActionResultDialogTranslation:columns` (regenerated in e839d61;
`check:authorable-surface` green on it). The preflight node has no row,
because `ActionPreflightTranslationSchema` is module-local and not on
the walk. `Metadata-protocol: added` follows from that row and from the
new key a bundle author can write; the spec changeset is `minor`.
## Tests
- Spec `src/system/i18n-resolver.test.ts`, new `describe('answer table
column labels …')` (7 cases): a column header resolved in zh-CN (a
dotted column path as one key, an unlabelled column gaining one), the en
bundle read in en with authored headers kept where en has no key, a
bundle without any column key answering exactly as before and still
parsing, the fallback chain per column, the preflight block,
`translateAction` on both blocks, and the schema refusing a flat string
where the per-field map belongs.
- Lint `src/i18n-walk.test.ts`, new `describe('collectExpectedEntries —
answer table column labels')`: the walk lists one key per labelled
column beside the field key, inline locale maps kept, for `resultDialog`
and `preflight`.
- Lint `src/validate-translation-references.test.ts`, new
`describe('resultDialog.columns / preflight.columns')` (3 cases) plus
the two new rows in the action-shape coverage pin and the real-instance
control.
- Console
`ui/packages/i18n/src/__tests__/useObjectLabel-actionResultDialog.test.tsx`,
new top-level `describe` (2 cases): headers drawn from the zh-CN bundle
and from the en bundle after a language switch, the preflight overlay,
and a bundle with no column key keeping every authored header.
Package suites, local, at `6a8399c1` (each under
`scripts/pm/os-verify-lock.sh`, `VERDICT command-exit 0`):
<details><summary>Suite readings</summary>
- `pnpm --filter @objectstack/spec test`: Test Files 848 passed (848),
Tests 27189 passed, 1 todo.
- `pnpm --filter @objectstack/lint test`: Test Files 216 passed (216),
Tests 9163 passed.
- `pnpm --filter @objectstack/platform-objects test`: Test Files 123
passed (123), Tests 2046 passed.
- `pnpm --dir ui --filter @object-ui/i18n test`: Test Files 102 passed
(102), Tests 1896 passed, 13 skipped.
- `pnpm --filter @objectstack/spec typecheck`, `pnpm --filter
@objectstack/lint typecheck`, `@object-ui/i18n type-check`: exit 0.
</details>
<details><summary>Ablations (one per tested behaviour, through
scripts/ablation-replace.mjs; each restore proved blob == HEAD and git
diff HEAD empty)</summary>
- `i18n-resolver.ts` `overlayAnswerColumnLabels`, the lookup replaced by
`undefined`: `i18n-resolver.test.ts` 5 failed / 526 passed (the five
column cases that read a translated header; the two that assert authored
headers and parsing stay green, as they should).
- `i18n-walk.ts` `pushAnswerTableColumns` returning at once:
`i18n-walk.test.ts` 2 failed / 8 passed.
- `validate-translation-references.ts` `checkActionAnswerTableColumns`
returning at once: 3 failed / 247 passed (the two refusal cases and the
coverage pin's ghost legs).
- `useObjectLabel.ts` `overlayColumnLabels`, the lookup replaced by
`undefined`: `useObjectLabel-actionResultDialog.test.tsx` 1 failed / 4
passed.
</details>
## Acceptance notes
- **Live reading needed a stand-in for one hop, because of a separate
defect.** On current `main` the console's Import Users action answers
`400 INVALID_REQUEST` "Unknown field(s): organizationId": the action
door (`packages/runtime/src/action-execution.ts`, the identity-route
`organizationId` stamp) adds a key the import door
(`packages/plugins/plugin-auth/src/pending-sso-users.ts`) refuses. Filed
as #34912 by the seat; not touched here. For the reading, a Playwright
route re-sent the dialog's own params to the import door itself (`POST
/api/v1/auth/admin/import-sso-users`), so the answer the dialog drew is
the door's real one; nothing else was stubbed.
- The result table's headers wrap one character per line in the narrow
reveal dialog when nine columns are drawn (visible in the zh-CN
reading); that is the existing dialog width, not the labels, and it is
the same in en with longer words. Noted, not filed.
- On the Users list the `source` option `idp_pending` draws "Pending SSO
Sign-In" in zh-CN. Noted, outside this card.
- `Skills-docs`: `skills/objectstack-i18n/SKILL.md` teaches every action
bundle key and should gain the two `columns` keys; filed as #34917 (a
`domain:skills` follow-up, governed surface).
- No review was requested on this pull: under the seat order the
assignee is the claim's `Account:` and the seat hands over reviews.
## Verification
**Live, zh-CN, the real console** (Vite from this branch over
`@objectstack/example-showcase` booted `--fresh` with
`OS_CLOUD_MANAGED=1` so the managed action is offered; Playwright,
locale `zh-CN`): Setup → 用户 → overflow → 导入用户, CSV with one good and one
bad row, 确认. The result dialog titled 导入完成 drew the `rows` table with
headers
`["行","邮箱","成功","已在待激活中,已再次通知","已通知托管组织","未通知的原因","未添加的原因","未应用(请在记录上设置)","上级"]`
and the same run in `en` drew `["Row","Email","Succeeded","Already
pending, told again","Hosting organization told","Why not told","Not
added because","Not applied (set these on the record)","Manager"]`. Not
run live on `main`: there the bundles carry no `columns` key and the
overlay reads none, so the table draws the authored English headers in
every locale (the card's premise, read in source).
**Server half:** `GET /api/v1/meta/object/sys_user` with
`Accept-Language: zh-CN` serves
`import_sso_users.resultDialog.fields[rows].columns[].label` as the nine
Chinese headers above; with `en`, the authored English.
<details><summary>Derived gates (dispatch-gates --commands at 6a8399c:
120 families, all run locally)</summary>
- 116 exited 0 on the first pass, including `check:i18n`,
`check:i18n-walk-parity`, `check:i18n-stale-fill`, spec
`check:generated` (all 14 current), `check:authorable-surface`,
`check:liveness`, `check:docs`, `check:nul-bytes`,
`check:test-source-alias`.
- `spec check:api-surface` and `spec check:skill-examples` refused with
exit 3 (dist older than a source file an ablation restore had
rewritten); after the rebuild both exit 0 ("public API surface + factory
signatures unchanged", "347 prose examples type-check").
- `check:watch-hint-literal` exited 1 on a temp file another gate run
deleted under it (ENOENT on an `i18n-extract.config.bundled_*.mjs`);
rerun alone: exit 0.
- `node scripts/check-plugin-teardown-shape.mjs --self-test`: exit 3,
the shallow clone cannot reach its pinned positive-control commit. NOT
MEASURED locally; CI's checkout runs it.
- Outside the derived list: `pnpm check:i18n-coverage` exit 0 ("14
config(s), 423 baselined untranslated string(s), none new").
- `dispatch-gates --ran`: 120 of 120 accounted.
- Size: 26 files, +825 / -51 against `main`; no governed path. `main`
moved 11 commits since the branch point, none in a file this diff
touches and none in `packages/spec`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01WGufzfRcWkapqoXk7QZVob
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzfRcWkapqoXk7QZVob -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(spec, lint, i18n): an action answer table's column headers have a translation bundle key
9
+
10
+
Clause-②: yes (widening) — `ActionResultDialogTranslationSchema` and the action `preflight` translation node accept a new optional `columns` map, `columns.<field path>.<column path>` (both keys literal, dots included), beside `fields`; every bundle that parsed before parses unchanged and reads the same.
A `format: 'table'` field in an action's `resultDialog.fields` or `preflight.fields` declares `columns: [{ path, label }]`, and each column's `label` is translatable, but no bundle key carried it, so a table's headers stayed in the authored language in every locale. The key is `objects.<object>._actions.<action>.resultDialog.columns.<field path>.<column path>` (and `….preflight.columns.…`; `globalActions.<action>.…` for an object-less action):
-`os i18n extract` lists one key per labelled column, `os validate` refuses a column key that names no declared table field or column (`translation-target-unknown`), and `resolveActionResultDialog` / `resolveActionPreflight` (so `translateAction` and the served metadata) and the console's `useObjectLabel` overlay the translated header; a column with no key keeps its authored label.
24
+
- The platform bundles carry the nine column headers of `sys_user.import_sso_users`'s result table in every shipped locale.
Copy file name to clipboardExpand all lines: content/docs/protocol/kernel/i18n-standard.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1155,6 +1155,7 @@ beneath an action entry are judged the same way under either.
1155
1155
|`{action}.params.{param}.options.{value}`| an option's stored **`value`** in that param's inline `options` — a warning, as on a field. A param that references a `field` and declares no inline `options` takes the field's list when the dialog renders, so its option keys are not judged |
1156
1156
|`{action}.outcomeMessages.{outcome}`| an outcome the action's own `outcomeMessages` declares |
1157
1157
|`{action}.resultDialog.fields.{path}`| the literal `path` of a field the action's `resultDialog.fields[]` declares — dots included, so `client.secret` is one key |
1158
+
|`{action}.resultDialog.columns.{path}.{column}` / `{action}.preflight.columns.{path}.{column}`| a column header of a table: `{path}` the literal `path` of a `format: 'table'` field in that block's `fields[]`, `{column}` the literal `path` of one of its `columns[]` — dots included at both levels, so `columns.rows["error.message"]` is two keys deep, not three |
1158
1159
|`{action}.resultDialog.title` / `.description` / `.acknowledge`| an action that declares a `resultDialog`, whether or not the dialog sets that text itself — for an action that declares none, nothing reads the dialog's copy |
1159
1160
|`apps.{app}`| an app declared, or one a `navigationContributions` entry anywhere in the artifact contributes into — including an app owned outside the artifact; under an app that is only contributed into, `apps.{app}.label` may be left out (the owning package's label survives the merge) |
1160
1161
|`apps.{app}.navigation.{id}`| a navigation item `id` the app declares (nested `children` and `areas[]` included) or one contributed into it; under an app that is only contributed into, the contributed ids alone |
|**fields**|`Record<string, string>`| optional | Result field labels keyed by the literal field path declared in the action metadata (keys may contain dots) |
37
+
|**columns**|`Record<string, Record<string, string>>`| optional | Table column header labels: keyed by the literal path of a `format: 'table'` field, then by the literal path of one of its `columns[]` (keys may contain dots) |
37
38
38
39
39
40
---
@@ -136,8 +137,8 @@ Translation data for a single field
136
137
|**cancelText**|`string`| optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
137
138
|**outcomeMessages**|`Record<string, string>`| optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
@@ -241,8 +242,8 @@ Translation data for a single object
241
242
|**cancelText**|`string`| optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
242
243
|**outcomeMessages**|`Record<string, string>`| optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
@@ -421,8 +422,8 @@ Translation data for a single object
421
422
|**cancelText**|`string`| optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
422
423
|**outcomeMessages**|`Record<string, string>`| optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
@@ -664,8 +665,8 @@ Translation data for a single object
664
665
|**cancelText**|`string`| optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
665
666
|**outcomeMessages**|`Record<string, string>`| optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
@@ -876,8 +877,8 @@ Translation data for a single object
876
877
|**cancelText**|`string`| optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
877
878
|**outcomeMessages**|`Record<string, string>`| optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
Copy file name to clipboardExpand all lines: content/docs/ui/translations.mdx
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,7 @@ export default defineStack({
76
76
| Bulk-action copy on a list view (button, confirm prompt, dialog fields) |`objects.<name>._views.<view>.bulkActions.<def>.label` / `.confirmText` / `.confirmLabel` / `.params.<param>.label` / `.help` / `.placeholder` — a bulk param's hint is `help`, not `helpText`|
| Action result dialogs (title / description / acknowledge / field labels) |`objects.<name>._actions.<action>.resultDialog`|
79
+
| Column headers of a table in an action's result dialog or preflight panel |`objects.<name>._actions.<action>.resultDialog.columns.<field path>.<column path>` / `.preflight.columns.<field path>.<column path>` — a sibling of `fields`, both paths written literally, dots included |
79
80
| Form sections |`objects.<name>._sections.<section>`|
0 commit comments