fix(i18n): key ObjectView 的 create/edit/view 表单标题 (#3462) - #3468
Merged
Conversation
`ObjectView.getFormTitle()` 用模板字符串自拼三个英文动词
(`Create/Edit/View ${objectLabel}`),zh 会话打开抽屉读到的是
"View 联系人" —— 英文动词贴在本地化标签前。三个消费点全是可见标题:
`renderDrawerForm` 的 DrawerTitle、`renderModalForm` 的 DialogTitle,
以及 popover 分支传给 `NavigationOverlay` 的 title prop。
三个动词分支改走 `form.createTitle` / `form.editTitle` /
`form.viewTitle`。没有新造 key 家族:前两个十包已有,且 app-shell 的
page 模式记录表单(RecordFormPage / AppContent)用的正是它们 —— 抽屉、
弹窗、浮层只是同一个标题的另一个承载面,复用同一组 key 才不会漂。
只有第三个动词没有兄弟,`form.viewTitle` 按各包既有排布补进十个语言包。
`schema.form?.title` 覆盖分支与 `default` 分支保持原样。英文输出逐字节
不变,无 provider 时由 `VIEW_DEFAULT_TRANSLATIONS` 兜底。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 #3462
#3426 / PR #3457 与 #3459 / PR #3464 同族的又一个调用点。
前提复核(先于实现)
在
origin/main(84bd39e) 上确认 issue 前提仍然成立:getFormTitle()(行号已漂到 903)仍在用模板字符串自拼三个英文动词,三个消费点也都还读它 ——renderDrawerForm的DrawerTitle(937)、renderModalForm的DialogTitle(954)、popover 分支传给NavigationOverlay的titleprop(1276)。zh 会话打开抽屉读到的是 "View 联系人" —— 英文动词贴在本地化标签前。这不是推断:反向验证时把
ObjectView.tsx还原成 main 的版本再跑新测试,渲染出的 DOM 里字面量出现了View 联系人/Create 联系人/Edit 联系人,与报告人的复现完全一致。可达性门槛比 #3459 的 split 分支还低:
ObjectViewSchema.layout默认即'drawer',而navigation是object-view注册块上已声明的可编写输入,其mode联合类型含drawer/modal/popover;任一模式下点行即setFormMode('view')并打开容器。app-shell 包装器钉layout: 'page'是宿主覆盖已注册块,不能证明分支已死。改法:复用既有 key 家族,而不是新造
按 PM 裁定「先在十个语言包里找现成的
Create/Edit/View形状的 key,找不到再造console.objectView.*」—— 找到了:form.createTitle=Create {{object}}form.editTitle=Edit {{object}}这两个 key 十包全有,而且 app-shell 的 page 模式记录表单标题用的正是它们(
RecordFormPage.tsx:131-132、AppContent.tsx:787-788)。抽屉 / 弹窗 / 浮层的标题只是同一个标题的另一个承载面,所以解析同一组 key;另造一套console.objectView.*只会保证两处拼写迟早漂开(zh 本身就区分 新建 与 创建),而这恰是本系列 issue 要治的病。只有第三个动词没有兄弟,新增
form.viewTitle到十个语言包,按各包 create/edit 双胞胎的既有语序排布,而非「翻译动词再拼标签」:Create {{object}}Edit {{object}}View {{object}}新建{{object}}编辑{{object}}查看{{object}}{{object}} erstellen{{object}} bearbeiten{{object}} anzeigen{{object}}を作成{{object}}を編集{{object}}を表示{{object}} 생성{{object}} 편집{{object}} 보기Créer {{object}}Modifier {{object}}Afficher {{object}}Crear {{object}}Editar {{object}}Ver {{object}}Criar {{object}}Editar {{object}}Ver {{object}}Создать {{object}}Редактировать {{object}}Просмотреть {{object}}إنشاء {{object}}تعديل {{object}}عرض {{object}}VIEW_DEFAULT_TRANSLATIONS(#3464 在本文件建好的兜底表)补上三条英文,供无I18nProvider的宿主使用。两个分支刻意保持原样,并各有测试钉住:
schema.form?.title覆盖(作者写了标题就用作者的,任何语言下都是)、以及default分支(只回标签,没有动词可译)。工具栏那个「新建」按钮仍解析
console.objectView.new,刻意没有拿来当标题:按钮动词与标题是两种语境,把它们并成一个 key 正是下一次同形漂移的起点。与 PM 裁定的一处偏差(需知会)
插值变量是
{{object}}而非派发单里写的{{label}}。这是复用既有form.*Title家族的机械后果 —— 该家族声明的就是{{object}},而all-locales-key-parity的占位符守卫是按 key 逐个比对占位符集合的;给viewTitle单独用{{label}}会让它与两个兄弟不一致。若维护者更希望另起console.objectView.*家族,改回来的成本很小,但代价是与 app-shell 的 page 模式标题分家。测试
新增两个文件,分文件的理由沿用 #3464:
createI18n会把实例注册成 react-i18next 的模块级全局默认,该注册在cleanup()后仍在,所以「无 provider」断言必须独占一个文件。ObjectView.formTitleI18n.test.tsx—— 13 例,三个动词 × en/zh/de(+ view 的 ja),外加 modalDialogTitle、popoverNavigationOverlay两个消费点,以及schema.form.title覆盖。ObjectView.formTitleNoProviderFallback.test.tsx—— 4 例,无 provider 时三个动词的英文兜底 + 无 label 时回落到objectName。de 是承重断言:德语动词在标签之后(
Kontakte anzeigen),任何「翻译动词再拼接」的写法在任何动词取值下都产不出这个语序 —— 将来若有人把 key 退化成动词查表,这条会红。反向验证(方向在跑之前就定好了)
预测:zh/de/ja 各动词 —— 改前红、改后绿;en、无 provider、
form.title覆盖 —— 两侧皆绿(逐字节钉死)。用
git checkout origin/main -- packages/plugin-view/src/ObjectView.tsx还原实现、保留新测试与语言包后实测:9 条红的全部且仅为 zh/de/ja 用例(view/edit/create 三态 + modal + popover);8 条绿的是 3 条 en + 1 条
form.title覆盖 + 4 条无 provider 兜底。方向与预测完全一致。恢复实现后 17/17 全绿。完整跑批(仓库根,flock 串行,
--maxWorkers=2)含
all-locales-key-parity.test.ts(十包 key 与占位符全量对齐)。消费半径清扫
按规则用 key 的消费半径而非改动包来扫 fixture:全仓 grep 旧标题字面量(
View Contacts等)与getFormTitle,除本 PR 自己的测试外,没有任何 e2e spec 或宿主测试按旧英文串寻址这块 chrome —— 英文输出逐字节不变,所以本来也无需改动。字节自查
node scripts/check-control-bytes.mjs通过(扫 3668 个文件);另按规则做了超出闸门的自查grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f]',改动文件全部干净。Changeset:
.changeset/object-view-form-title-i18n-3462.md(@object-ui/plugin-view+@object-ui/i18n,均为 patch)。Generated by Claude Code