fix(metadata-admin): 页面块检查器自身的 chrome 跟随会话语言 (#3963) - #3980
Merged
Conversation
…3963) The panel's own JSX carried English that no translation table could reach — the row-adder of every field list, the remove aria-labels, the JSON parse error and two fallback placeholders. All resolve through the catalog now: five new `engine.inspector.pageBlock.*` keys in both locales, plus the existing `engine.form.invalidJson` reused rather than duplicated. `InspectorJsonField` now stores the parse failure as a boolean and resolves the message at render, so it follows a later locale switch instead of freezing the language that was active when the parse failed. #3913's boundary pin (which asserted these literals were STILL English) is tightened into a describe that asserts the same sites resolve through the catalog in both locales, plus a completeness pin that reads the key list back out of the component source.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Collaborator
Author
|
PM 验收(session_01GTRjn8xBqp75dk7kFupVRt):通过,转 ready 并挂 auto-merge。#3963 落地 —— PageBlockInspector 的 i18n 双单(#3913 表数据 + #3963 chrome)至此闭环。 核验记录(head
out-of-scope #3979(block-config placeholder 混合面)由 PM 分诊(候选晋级,「不能照抄 label 改必填”的取舍提醒已记入正文)。 Generated by Claude Code |
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.
Fixes #3963
基:
5bfaabde0(含 #3913 的落地62c644168,已git merge-base --is-ancestor核验)。症状与机制
#3913(PR #3970)修的是
previews/block-config.ts的 curated 属性 label —— 表数据。本单是另一条机制:PageBlockInspector.tsx自己 JSX 里的硬编码英文,从来不是block-config的 label,任何翻译表都碰不到。#3913 之后症状恰好反了过来:zh-CN 管理员打开record:details检查器,「分区」「字段」都是中文,每个字段列表下面的添加按钮却是英文Add。字面量清扫(逐处 grep,含处置)
ObjectPickerField自由文本兜底placeholder="snake_case object"…pageBlock.objectPlaceholderFieldListField自由文本行placeholder="field name"…pageBlock.fieldPlaceholderFieldListField行删除aria-label="Remove"…pageBlock.list.removeFieldListField行添加Add…pageBlock.list.addInspectorJsonField解析错误setError('Invalid JSON')engine.form.invalidJson(不新增)string-list分支行删除aria-label="Remove"…pageBlock.list.removestring-list分支行添加Add…pageBlock.list.addarray分支 item 卡片删除aria-label="Remove item"…pageBlock.list.removeItem清扫方式:
aria-label=/title=/alt=/placeholder=属性全量列举 + 自闭合标签后的裸文本节点扫描。零残留,唯一剩下的属性字面量是SelectValue placeholder="—"(全角破折号,无语言内容,不译)。阳性反查:对同一文件 grepAdd|Remove|Invalid|field name|snake_case,命中只剩标识符(InspectorRemoveButton、setInvalid)与注释,证明模式确实找得到这些词、而不是模式失效。分诊评论给的 main 锚点(61/101/147/440/465)逐条对上,只有行号随 #3913 漂移。
键命名:共享键,且不放在
.field.下分诊席把「共享
addRow键 vs 逐点键」留给 PR 决定。选共享键:两个添加按钮语义完全相同(给这个标量列表加一行),两处本就没有 per-field 文案。逐点键会造出两个值相同、译者无从区分的键 —— 「一键一义」在反方向失效。同时对 issue 建议的键名
engine.inspector.pageBlock.field.addRow做了一处偏离:不放进.field.命名空间。.field.*/.add.*/.option.*三支的契约是「由 label 在BLOCK_CONFIG里的位置推导」,previews/__tests__/block-config-i18n.test.ts正是照这个形状反推的;chrome 键混进去会长得像一个叫addRow的块类型,而这恰是那条推导断言在防的复制粘贴失误。所以 chrome 键与kind/close/properties/advanced/remove平级:list.*这个子命名空间照抄engine.inspector.flowNode.list.*—— 兄弟面板里同一种列表编辑器的现成惯例;…Placeholder后缀照抄同表已有的engine.inspector.widget.datasetPlaceholder。zh 取值与既有惯例对齐(删除同engine.form.remove,删除项同flowNode.list.remove)。没有复用
engine.form.add/engine.form.remove(值恰好也是Add/添加):那是 SchemaForm 终端用户表单的面,复用会让设计器检查器的措辞随另一个面板改动而变 —— PR #3970 对同一面板已论证过这条 split-brain 取舍。但Invalid JSON反过来必须复用:engine.form.invalidJson已存在,且共享的translateValidationMessage()已经把'invalid json'映射到它,这里原本是把现成键绕过去了,新增第二个键就是给同一个事实造第二种措辞。en 侧五个新键的值逐字等于原来的字面量,所以英文面无漂移(下面 en 钉与
check:i18n-drift双向印证)。顺带修正:错误消息不再冻结语言
InspectorJsonField原来把已翻译的字符串存进 state。改成存布尔事实、渲染时解析 —— 否则解析失败后切换语言,消息会停在失败当时那门语言。state 存事实、渲染管措辞。PR #3970 边界钉的收紧
PR #3970 里那条
leaves only the known non-block-config chrome in English (objectui#3963)断言这些英文仍然存在 —— 设计好的接力信号。它按预期精确翻红,收紧而非删除:原位置留下一段注释说明「边界移动了、没有消失」,断言本身变成新的 describe,钉同一批站点现在经由目录解析、两语齐备。钉子
PageBlockInspector's own chrome follows the locale (#3963)(5 例)—— zh-CN 下八处站点全中文 + 英文原文逐条queryBy…为空;en-US 下逐条仍是原英文(基准语言未动);string-list分支单独一例(它与FieldListField是同一套 chrome 的两份独立拷贝,上面的 describe 没有任何 fixture 渲染到它);object picker 的 placeholder;JSON 解析错误在两语下的解析值。两个aria-label与两个 placeholder 对文本查询和截图都不可见,所以断言走getByLabelText/getByPlaceholderText—— 这也正是它们能躲过 页面块检查器的 PROPERTIES 面在 zh-CN 会话下是英文的 —— curated 字段 label 走字面量、只有外围章节标题走t()#3913 那轮 review 的原因。chrome keys resolve in both locales (#3963)(4 例)—— 形状照 页面块检查器的 PROPERTIES 面在 zh-CN 会话下是英文的 —— curated 字段 label 走字面量、只有外围章节标题走t()#3913 的结构钉,但适配了唯一的差别:chrome 键没有「位置」可推导,它们是一个文件里的t('…')调用点。所以键表不是手抄进测试,而是从组件源码读回来(readFileSync+ 正则取字面量键,动态t(f.label)自然落在 block-config 那条钉里),于是将来谁加一个只有 en 译文的 chrome 键,这里直接翻红,不依赖谁记得来扩列表。完整性照 页面块检查器的 PROPERTIES 面在 zh-CN 会话下是英文的 —— curated 字段 label 走字面量、只有外围章节标题走t()#3913 的写法用t()度量(未命中原样返回键,t(k,l) === k恰好就是「这门语言没有条目」)。另有LOCALE_INVARIANT台账一条:engine.inspector.pageBlock.id(ID是缩写,zh 不译)—— 台账而非放宽,其余全部保持红。反向验证(方向先预判、写在 scratchpad 再跑;两个变异均已回退,不提交)
变异 A —— 还原
aria-label="Remove item"字面量。 预判:zh 例翻红、键扫描例翻红,而 en 例保持绿(还原的字面量就是 en 值 —— en 钉是漂移守卫,不是回归探测器,这个方向是反的,如实记录)。实测Tests 2 failed | 14 passed,两处预判的翻红点逐条命中(Unable to find a label with the text of: 删除项;expected [ …(16) ] to include 'engine.inspector.pageBlock.list.remov…'),en 例如预判保持绿。与预判的偏差:我原写「预计 3 条红」,把同一个用例里的两句断言数成了两条 —— 首句断言抛出后第二句不再执行,用例数是 2。方向全部吻合,计数是我数错了。变异 B —— 删掉 zh 侧
list.add一条。 预判:every key resolves in zh-CN精确指名该键;zh-CN is actually translated, not a copy of en-US保持绿(t()兜底返回键本身,与Add不同,那条断言无从触发 —— 与 PR #3970 对自己那个变异测到的方向一致);两条渲染例翻红。实测Tests 5 failed | 11 passed,AssertionError: … + [ "engine.inspector.pageBlock.list.add" ]精确指名,「zh 不等于 en」如预判保持绿。比预判多两条红:#3913 原有的两条 zh 渲染例(renders curated field labels…、translates the array add button…)也翻了 —— 它们的expectNoRawKeys()扫的是整个面板 body,于是也看见了 chrome 漏键渲染出的裸键串。这是「诊断变多而非变少」的方向,我低估了爆炸半径,如实记录。消费半径清扫
按规则不只扫改动包:全仓 grep 断言这些字面量的测试/fixture/e2e,以及渲染
PageBlockInspector的全部测试文件 —— 命中只在packages/app-shell/src/views/metadata-admin内(block-config-i18n、page-block-path、visibleWhen、sectionName、本文件),已被下面的全量跑覆盖;其它包没有 fixture 喂给这个组件。校验记录(全部实测)
pnpm --workspace-concurrency=2 --filter '@object-ui/app-shell^...' build(持共享锁)—— 通过。pnpm exec vitest run packages/app-shell/src/views/metadata-admin --maxWorkers=2(持共享锁,NODE_OPTIONS=--max-old-space-size=4096)——Test Files 135 passed (135)/Tests 1360 passed | 1 skipped (1361),exit=0。pnpm exec turbo run type-check --concurrency=2——78 successful, 78 total,exit=0。pnpm check:i18n-keysexit=0(2316/2316 literal keys resolve;module-local table计数 1076 → 1084,恰好等于本 PR 新增的 8 个t()调用点)。pnpm check:i18n-driftexit=0(0 en value(s) changed)。两张门都不覆盖metadata-admin/i18n.ts本表(它在EXCLUDED_TRANSLATORS/ 门只读 locale pack),所以它们的绿是「未被本改动破坏」,表内完整性由上面第 2 条钉负责。node scripts/check-control-bytes.mjsOK(3874 文件);另对 3 个改动文件做了grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]'自扫(gate 有已知盲区),干净。pnpm exec eslint三个改动文件:0 errors(33 条既存any/react-refresh warning,与本改动无关)。node scripts/check-changeset-presence.mjsexit=0;changeset@object-ui/app-shellpatch。边界
previews/block-config.ts(页面块检查器的 PROPERTIES 面在 zh-CN 会话下是英文的 —— curated 字段 label 走字面量、只有外围章节标题走t()#3913 已定型)。BlockPropField没有格式/校验能力位 —— 所有标识符类字段(sectionname、tabkey、accordionvalue)只能靠 placeholder 陈述约定 #3912 的BlockPropField能力位面。id,于是同一个控件被两个同文本 label 引用(可访问名重复),而它自己的通用分支一直是对的 #3962 的ActionParamDialog(同包不同文件,不相交)。block-config.ts的placeholder列仍是英文显示文本(8 处有语言内容,如lucide icon name×4、snake_case, e.g. contact_info)—— 与 页面块检查器的 PROPERTIES 面在 zh-CN 会话下是英文的 —— curated 字段 label 走字面量、只有外围章节标题走t()#3913 同一条机制、同一个文件的另一列,不是本单的面,已另开 block-config.ts 的 8 个 placeholder 仍是英文显示文本 —— #3913 只搬了 label/addLabel/option,zh-CN 面板里的输入框提示还是 "lucide icon name" #3979,未夹带。Generated by Claude Code