Repository navigation
Commit 51992df
fix(i18n): Studio edits the Traditional Chinese entry in a Traditional session and never overwrites the other script (#31089)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoKnw5nKcC7y1QqoHK4wxk2W)_
Fixes #31074
Clause-②: no
Metadata-protocol: none
Clause-② is `no`: `SupportedLocale` gains `'zh-Hant'`, but it lives in
`@object-ui/app-shell`, which is private and exports only its root,
which does not carry that type. `@object-ui/i18n` and `@objectstack/cli`
change behaviour, not their exports. Metadata-protocol is `none`: what
an author can write is unchanged.
## 维护者速读
- 改了什么:繁体中文(zh-Hant / zh-TW / zh-HK)会话进入 Studio
时,设计器语言不再一律按简体处理;导航设计器显示并修改的是侧边栏同样显示的繁体条目。只写了简体的标签,在繁体会话里修改时会新增一条繁体,不再覆盖简体原文。`os
i18n check` 也把“繁体条目留空”算作缺翻译。
- 为什么改:之前繁体管理员在 Studio
看到简体名称,改名会覆盖简体作者写的文字,繁体用户看到的条目却不更新;留空的繁体条目还被报告为“已翻译”。
- 风险与回滚:只影响中文会话;简体会话、英文及其他语言的设计器行为与改前一致(有测试钉住)。Studio
的界面文字在繁体会话下沿用简体(studio 词库只有一份中文),这是有意的回退。回滚即还原本 PR。
- 先看:`ui/packages/app-shell/src/views/metadata-admin/i18n.ts` 的
`designerLocaleOf`;`ui/packages/i18n/src/pickLocalized.ts` 的
`localeWriteKey`(共用写入分支的脚本检查);`packages/cli/src/utils/i18n-coverage.ts`
的 `inlineLocaleText`。
- 两分钟验证:`pnpm --dir ui exec vitest run
packages/app-shell/src/views/metadata-admin/useMetadataLocale.sessionScript-31074.test.tsx
packages/i18n/src/__tests__/setLocalized.test.ts`,预期全绿。
- 需要你做的:无,席位落地。
- **席位意见**:ui 席 2 对照 head `410d25d6` 的 diff 复核:15 个文件、+304 /
−60,无受治理路径,不碰 `packages/spec/src`,不欠契约复审。Studio
设计器语言改为跟随会话书写:繁体会话(zh-Hant / zh-TW / zh-HK)按 `zh-Hant`
读写标签条目,界面文字仍用简体目录;写入侧遇到只有另一种书写的标签时新增本书写条目、不覆盖原文;CLI
覆盖率把渲染器实际显示的空条目算作缺口。现场三项读数与三组消融见正文。CI 全绿,同意落地。
## What changes
1. **The designer locale follows the session script.**
`useMetadataLocale` (`metadata-admin/i18n.ts`) no longer collapses every
`zh*` to `'zh-CN'`. A new pure `designerLocaleOf(language)` resolves the
session language through the console's own `resolveBuiltInLanguage`. A
session the console serves in `zh-Hant` (`zh-Hant`, `zh-TW`, `zh-HK`, …)
designs as `'zh-Hant'`, every other Chinese session designs as
`'zh-CN'`, and anything else as `'en-US'`. `SupportedLocale` gains
`'zh-Hant'`.
2. **An edit in a script the map lacks adds its own entry.** The shared
write limb (`localeWriteKey` in `pickLocalized.ts`, behind
`setLocalized` / `clearLocalized`) stops owning an entry of the other
script. A `zh-Hant` edit over `{ en, zh }` or `{ en, 'zh-CN' }` adds
`zh-Hant`, and a clear there removes nothing. The same holds the other
way round. Where the table does not name a script subtag (`zh-Hant-US`),
the limb does not assume it is the editor's own. The read side is
unchanged. `navItemLabel`'s `renamedLabel` / `clearedLabel` now go
through `setLocalized` / `clearLocalized` instead of asking
`resolveI18nLabel` for the owned key, so they inherit the rule. Their
own "sibling-only map ⇒ add the exact tag" rule (objectui#11196) is kept
in `ownsAnEntry`.
3. **CLI coverage.** `inlineLocaleText` judges an empty entry after the
shared resolver picks, not before. A blank entry the renderer shows is a
gap: `{ 'zh-CN': '成员', 'zh-TW': '' }` at `zh-Hant`, and `{ zh: '成员',
'zh-CN': '' }` at `zh-CN`. Server seat: no objection (#30985,
6702009928).
### Studio surfaces that read the designer locale
- **Chrome (falls back to Simplified).** Of the 66 non-test files that
call `useMetadataLocale`, and the components that take its value as a
prop, almost all use it for chrome only (`t()` / `tFormat()` /
`tOptional()` → `studioString`). The `studio` namespace ships one
Chinese catalogue (`zh`), and `resolveStudioLanguage('zh-Hant')` serves
it, so a Traditional designer reads Simplified chrome and never English.
No Traditional strings were invented. Three chrome sites compared `===
'zh-CN'` and would have dropped to English, so they now use
`isZhLocale`: `PositionHoldersSection.tsx:110`,
`AssignedUsersSection.tsx:132` and `ResourceEditPage.tsx:3059`.
- **Label entries (follow the session script, no edit).** These pass the
same locale to `pickLocalized`, `resolveI18nLabel`, `navItemLabelText`
or `renamedLabel` / `clearedLabel`: `StudioNavItemInspector`,
`AppNavInspector`, `AppNavCanvas`, `InterfacesNavRail`,
`SourcePageProperties`, `StudioDesignSurface`, `ObjectActionsPanel`,
`ObjectListViewInspector` / `ObjectListViewTitle`,
`ListViewBulkActionsSection`, `AutomationsFlowRail`, `metadataError`,
`packageSurfaces`, `useDatasetCatalog`, `AppPreview`,
`DashboardPreview`, `ViewPreview`, `DashboardDefaultInspector`,
`DashboardWidgetInspector` and `ReportDefaultInspector`.
- **Not the designer locale.** `translationTable.ts` and `doc-draft.ts`
key by the translation or doc language the author picks, so they are
untouched.
### Re-pinned #31068 controls
These pinned the cross-script overwrite as "unchanged" and now pin the
added entry:
- `setLocalized.test.ts` UNCHANGED: `{ en, 'zh-CN' }` @ `zh-Hant` →
`zh-CN`; `{ en, zh }` @ `zh-TW` → `zh`; `{ en, 'zh-HK' }` @ `zh-Hans` →
`zh-HK`. All three moved to the #31074 block, where they now add their
own tag.
- `navItemLabel.inherit-11196.test.ts` UNCHANGED: `{ en, zh }` renamed
in `zh-Hant` → `{ en, zh: 'RENAMED' }`. Moved to the #31074 block, where
it now adds `zh-Hant`.
- `i18n-inline-locale-map-coverage.test.ts`: `{ 'zh-CN': '成员', 'zh-TW':
'' }` @ `zh-Hant` was `'成员'` (covered) and is now a gap.
- `BuilderLanding.environmentOverlayCopy-12171.test.ts`
`DECLARED_LOCALES` lists `'zh-Hant'`. Its `satisfies
Record<SupportedLocale, true>` exists to fail the type-check until a new
locale is listed.
The spec twin is untouched. The `packages/spec` test's verbatim copy of
`pickLocalized` covers `splitScriptTagOf`, `localizedEntryKey` and
`pickLocalized`, and none of them changed: only `localeWriteKey` did.
Its provenance pin still names the revision the copy matches.
## Tests
Head `410d25d60c`.
<details><summary>Live readings (console from this tree, showcase
backend)</summary>
Setup: `examples/app-showcase` with two top-level nav labels set
locally, `nav_capability_map` = `{ en: 'Proj EN', zh: '简体项目', 'zh-TW':
'繁體專案' }` and `nav_start_here` = `{ en: 'Tasks EN', zh: '简体任务' }`. Their
`apps.showcase_app.navigation.<id>.label` bundle rows were dropped,
because a bundle row wins over the map. These edits were local only and
are reverted. Console: `ui/apps/console` vite with `objectui-locale =
zh-Hant`, logged in as admin, Studio → Interfaces.
1. The nav designer lists the first item as **繁體專案**, not 简体项目, in both
the rail and edit mode. On `main` it listed 简体项目 (measured on PR
#31068's head, #31074 body).
2. An inline rename of 繁體專案 to 改名繁體 autosaved `PUT
/api/v1/meta/app/showcase_app?mode=draft&package=com.example.showcase.custom`
with `label: { en: 'Proj EN', zh: '简体项目', 'zh-TW': '改名繁體' }`, so `zh-TW`
was updated and `zh` left untouched.
3. Renaming 简体任务 to 新增繁體 sent `label: { en: 'Tasks EN', zh: '简体任务',
'zh-Hant': '新增繁體' }`: `zh-Hant` was added and the Simplified text kept.
The inspector's Label field then read 新增繁體.
Studio chrome in that session is Simplified (界面 / 权限 / 属性), which is the
namespace fallback described above.
</details>
<details><summary>Suites</summary>
- `pnpm --dir ui exec vitest run packages/i18n/src/__tests__
packages/app-shell/src/views/metadata-admin/previews
packages/app-shell/src/views/metadata-admin/useMetadataLocale.sessionScript-31074.test.tsx`:
all pass.
- `pnpm --dir ui exec vitest run
packages/app-shell/src/views/studio-design/BuilderLanding.environmentOverlayCopy-12171.test.ts`:
4 pass.
- `packages/cli`: `vitest run
test/i18n-inline-locale-map-coverage.test.ts` 17 pass.
- Type-checks: `@object-ui/app-shell type-check`, `@object-ui/i18n
type-check` and `@objectstack/cli typecheck` (with
`NODE_OPTIONS=--max-old-space-size=6144`, because the 4096 run OOMed in
`check:test-typecheck`) all exit 0.
- `eslint` on every changed ui file: 0 errors.
</details>
<details><summary>Ablations (committed first, mutated,
restored)</summary>
- Designer locale (`designerLocaleOf` → always `'zh-CN'` for Chinese): 5
red in `useMetadataLocale.sessionScript-31074.test.tsx`, all of them the
zh-Hant / zh-TW / zh-HK rows and both rename rows. 0 controls red.
- Write limb (`localeWriteKey` → `return key`, which is the #31068
behaviour): 16 red across `setLocalized`, `clearLocalized`,
`navItemLabel` and the designer pin, all of them new #31074 pins. 0
controls red.
- CLI (`i18n-coverage.ts` at `main`): 2 red, the new empty-entry case
and the parity sweep over the two new maps.
</details>
<details><summary>Derived gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands` on `410d25d60c` derives
66 families, and all 66 exit 0. `--ran` reconciles them as 66 accounted
and 0 NOT-MEASURED. One family needed a rerun: `pnpm --dir ui exec
vitest run scripts/` first exited 1 on a 15 s timeout in
`dollar-dialect-alias-census.test.ts` while the live console was running
on the same box. A container restart then cut the sweep short. The
resumed sweep reran every family that had not yet recorded exit 0, and
that one passed. `node scripts/check-sdui-manifest.mjs` is in the
derived set and exits 0.
</details>
## Acceptance notes
- Studio chrome stays Simplified in a Traditional session. The `studio`
namespace has one Chinese catalogue, and inventing Traditional strings
is out of scope. Only the label entries an author reads and edits follow
the script.
- Reading is unchanged: a `zh-Hant` reader of `{ en, zh }` still sees
the `zh` text until a Traditional entry exists, and the first edit adds
one.
- `navItemLabel`'s "sibling-only map ⇒ add the exact tag" rule
(objectui#11196) is unchanged. For example, `{ en, 'zh-TW' }` renamed in
`zh-Hant` adds `zh-Hant`, as before.
<!-- signed: domain:ui#2 · os-tesla · session_01L9qibw7DekEe3wx5f3zphf
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4123865 commit 51992df
15 files changed
Lines changed: 304 additions & 60 deletions
File tree
- .changeset
- packages/cli
- src/utils
- test
- ui/packages
- app-shell/src/views
- metadata-admin
- previews
- studio-design
- i18n/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
545 | 545 | | |
546 | 546 | | |
547 | 547 | | |
548 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
549 | 554 | | |
550 | 555 | | |
551 | 556 | | |
552 | 557 | | |
553 | 558 | | |
554 | 559 | | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | 560 | | |
561 | 561 | | |
562 | 562 | | |
563 | 563 | | |
564 | | - | |
565 | | - | |
| 564 | + | |
| 565 | + | |
566 | 566 | | |
567 | 567 | | |
568 | | - | |
| 568 | + | |
| 569 | + | |
569 | 570 | | |
570 | 571 | | |
571 | 572 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
280 | 283 | | |
281 | 284 | | |
282 | 285 | | |
| |||
309 | 312 | | |
310 | 313 | | |
311 | 314 | | |
312 | | - | |
313 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
314 | 331 | | |
315 | 332 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | | - | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | | - | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
150 | | - | |
| 150 | + | |
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| |||
3056 | 3056 | | |
3057 | 3057 | | |
3058 | 3058 | | |
3059 | | - | |
| 3059 | + | |
3060 | 3060 | | |
3061 | 3061 | | |
3062 | 3062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
78 | 86 | | |
79 | 87 | | |
80 | 88 | | |
| |||
931 | 939 | | |
932 | 940 | | |
933 | 941 | | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
934 | 951 | | |
935 | 952 | | |
936 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
937 | 959 | | |
938 | 960 | | |
939 | 961 | | |
| |||
944 | 966 | | |
945 | 967 | | |
946 | 968 | | |
947 | | - | |
| 969 | + | |
948 | 970 | | |
949 | 971 | | |
950 | 972 | | |
951 | 973 | | |
952 | 974 | | |
953 | 975 | | |
954 | 976 | | |
955 | | - | |
| 977 | + | |
956 | 978 | | |
957 | 979 | | |
958 | 980 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
199 | | - | |
| 198 | + | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | | - | |
120 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
127 | | - | |
128 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
129 | 133 | | |
130 | 134 | | |
131 | 135 | | |
| |||
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
149 | 154 | | |
150 | 155 | | |
151 | 156 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
164 | 168 | | |
165 | | - | |
166 | | - | |
| 169 | + | |
167 | 170 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
| 171 | + | |
178 | 172 | | |
0 commit comments