Repository navigation
Commit dedc16c
feat(spec): Studio metadata-form select choices are translatable (metadataForms options slot) (#37569)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuPE7uyDAJyqjwwMzomWv5ff)_
Fixes #36950
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — `skills/objectstack-i18n/SKILL.md` names the
`metadataForms` group only, never its leaf keys; the group is
platform-owned, so no app author writes the new key
## 维护者速读
- 用户能看到什么变化:非英文的搭建者在 Studio
里打开对象、字段、报表、仪表盘、钩子、动作、页面、智能体、技能的配置表单时,下拉框里的选项名(例如共享模型「私有 —
仅所有者」、字段类型、删除行为、默认时间段)改为显示当前语言;以前这些选项在所有语言下都是英文,周围的字段名却已经翻译。
- 为什么做:翻译包里没有放选项名的位置,服务端也不翻译它们。
- 出错会怎样:只多翻译一层显示文字,选项的值不变,保存下来的数据不变;某个选项没有译文时仍显示原来的英文。
- 要你做什么:这个 PR 改动约 3,790 行(主要是 10 种语言的译文),超过 3,000 行,按规则需要授权审批人批准后由座位落地。
## What changes
**The reading the card asked for** (at `021524cd`,
`METADATA_FORM_REGISTRY` walked with the extractor's path rule): of the
18 registered Studio forms, 9 carry a select row with `options` —
`object`, `field`, `hook`, `report`, `dashboard`, `action`, `page`,
`agent`, `skill` — 38 rows, 187 options (185 distinct `type.path.value`
keys: `object`'s `fields.deleteBehavior` is listed twice, with the same
names). Every one is seen by a builder: the console's `SchemaForm`
renders `fieldSpec.options` ahead of the schema enum
(`ui/packages/app-shell/src/views/metadata-admin/SchemaForm.tsx`, the
enum/select branch), and the server translated only `label`, `helpText`
and `placeholder` of a form field.
- **Spec, translation slot**
(`packages/spec/src/system/translation.zod.ts`). A
`metadataForms.<type>.fields.<path>` entry accepts `options`: a record
from option `value` to its translated name, the shape
`objects.<object>.fields.<field>.options` already has. `choices` and
`values` are refused there, as on the object-field face, and the refusal
names `options` as the key to write (the `aliases` row of the strict
object is the rename hint of that unknown-key refusal, not an accepted
spelling).
- **Spec, resolver** (`packages/spec/src/system/i18n-resolver.ts`).
`translateFormField` overlays each `options[]` entry's `label` with the
translation keyed by its `value`, along the locale chain; an option with
no translation, or with a non-string value, is passed through unchanged.
This is the walker `resolveMetadataFormLabels` uses, which
`/api/v1/meta/types` localizes served forms with.
- **Lint, extractor** (`packages/lint/src/i18n-walk.ts`).
`walkFormField` emits
`metadataForms.<type>.fields.<path>.options.<value>` for every option of
a row, seeded with its English label, so `os i18n extract` and `pnpm
check:i18n` offer exactly the keys the resolver reads.
- **Platform-objects, shipped locales.** `node
scripts/check-i18n-bundles.mjs --write` added the 185 keys to all eleven
`*.metadata-forms.generated.ts` packs; the ten translated packs then got
hand-written names (ar, de, es-ES, fr, ja-JP, ko, pt-BR, ru, zh-CN,
zh-Hant) and a second `--write` dropped every source-hash row they had
seeded. The 17 Default Period choices take the wording of the console's
own period chip (`ui/packages/i18n/src/locales/*`,
`dashboard.filters.range.*` and `dashboard.filters.custom`), so the
period an author picks reads as the period a viewer sees. Loanwords that
read the same as English (`URL`, `HTML`, `JSON`, `Markdown`, and per
locale words such as de `Text`, fr `Date`) are spelled so they are not
byte-echoes of the source, which the catalog's zero-echo pins require
(`object-lifecycle-panel-echo-decisions.test.ts`,
`report-form-echo-decisions.test.ts`): for example zh-CN `网址(URL)`, de
`Textfeld`, fr `Date (sans heure)`.
- `content/docs/references/system/translation.mdx` regenerated
(`gen:docs`).
Small calls made here (no card): the rename hints for `choices` /
`values` mirror the object-field face; a non-string option value is
passed through untouched rather than stringified, since every option a
registered form lists has a string value (the reading found none other).
## Why
A non-English builder saw a translated field label with English choices
under it on every server-rendered Studio form. The bundle had no slot
for the names, so no locale could fix it.
## Verification
- `packages/spec/src/system/i18n-resolver.test.ts`, new top-level
describe "select option names": a choice is renamed by its value and
keeps its other keys; a value with no translation keeps its English
label; a nested repeater row is reached by its dot path; the input form
is not mutated.
-
`packages/platform-objects/src/metadata-translations/form-option-labels.test.ts`
(new): through the SERVED bundle and the real registry, the object
form's sharing model reads `私有 — 仅所有者` in zh-CN; the reading floor (≥30
option rows over ≥8 forms) holds; for each of the ten translated locales
every choice of every form select has a non-empty name that differs from
its English label.
- Local runs on this branch: `packages/spec` full suite green (vitest,
618 s); `packages/lint` 236 files / 9,680 tests green;
`packages/platform-objects` translations + metadata-translations 29
files green; `packages/cli` `test/i18n-extract.test.ts` green; `node
scripts/check-i18n-bundles.mjs` exit 0; `pnpm check:i18n-coverage` could
not measure here (exit 3: the example apps are not built in this
worktree), so CI carries that one; `pnpm --filter @objectstack/spec
check:generated` exit 0 after `gen:docs`.
- `node scripts/pm/overlap-check.mjs` exit 0 against `origin/main` and
the open PRs sharing these files (#37422, #37366).
Contract review (L2) is owed before landing: the diff changes
`packages/spec/src/**` and declares `Clause-②: yes (widening)`. Changed
lines exceed 3,000, so landing needs an authorized approval.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj)_
<!-- signed: repo:objectstack#2 · os-sales ·
session_01L6bhgUpnvPnJ1hR74pUrVj -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 6b7b305 commit dedc16c
19 files changed
Lines changed: 3463 additions & 416 deletions
File tree
- .changeset
- content/docs
- protocol/kernel
- references/system
- packages
- lint/src
- platform-objects/src
- apps/translations
- metadata-translations
- spec/src/system
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
575 | | - | |
| 575 | + | |
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| |||
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
586 | | - | |
587 | | - | |
| 586 | + | |
| 587 | + | |
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
| 362 | + | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| |||
806 | 806 | | |
807 | 807 | | |
808 | 808 | | |
809 | | - | |
| 809 | + | |
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
| |||
1030 | 1030 | | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | | - | |
| 1033 | + | |
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2753 | 2753 | | |
2754 | 2754 | | |
2755 | 2755 | | |
| 2756 | + | |
2756 | 2757 | | |
2757 | 2758 | | |
2758 | 2759 | | |
| |||
2819 | 2820 | | |
2820 | 2821 | | |
2821 | 2822 | | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
2822 | 2831 | | |
2823 | 2832 | | |
2824 | 2833 | | |
| |||
0 commit comments