fix(components,plugin-detail,i18n): 把剩余的控制台 chrome 无障碍名接入 i18n (objectstack#5430) - #3390
Merged
Merged
Conversation
…tstack#5430) 四处 icon-only 控件的可访问名仍是硬编码英文字面量;因为控件没有可见标签, 这个字面量对屏幕阅读器和 hover tooltip 而言就是控件本身。 - page:header 的 role="toolbar" → detail.pageHeaderActions - ReactionPicker 的 role="listbox" 弹层 → detail.emojiPicker - ReactionPicker 每个表情 chip(原本用字符串拼接内建英文复数) → detail.reactionCount / detail.reactionCountOne - NavigationOverlay 抽屉关闭 / 分栏面板关闭 → common.close / common.closePanel 复数项走本仓既有的双 key 约定(relatedRecords/relatedRecordOne、 recordCount/recordCountOne),不引入 i18next 的 _one/_other 后缀: zh/ja/ko 没有独立单数形式,那两个包会合理地缺 _one, all-locales-key-parity 会把它读成丢键。 五个新词条十个语言包全补。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
按 role+name 定位会同时命中 shadcn Sheet 原语自动渲染的关闭按钮
(packages/components/src/ui/sheet.tsx:80 的 sr-only "Close",属 No-Touch 区)。
NavigationOverlay 用 [&>button:last-of-type]:hidden 把它 CSS 隐藏,
真实浏览器里它不在无障碍树上;但 jsdom 不套用 Tailwind,RTL 仍能看到它,
于是 en 会话下 getByRole('button', { name: 'Close' }) 匹配到两个元素。
我们自己的关闭按钮是唯一带 title 的,按 title 定位才精确。
原语自身未翻译的标签是另一条越界发现,单独归档。
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 objectstack-ai/objectstack#5430
背景
四处 icon-only 控件的可访问名仍是硬编码英文字面量。因为这些控件没有可见标签,这个字面量对屏幕阅读器和 hover tooltip 而言就是控件本身 —— 在 zh/ja/es 会话下,它们是记录页 chrome 里仅剩的英文。
已对
origin/main逐条核实四处仍然存在(#5407/#3341 的同包改动已合入,行号有漂移,以下为当前 main 的行号):Page header actionspackages/components/src/renderers/layout/containers.tsx:1201——role="toolbar"的可访问名,就在 #5407 修掉的More actions触发器上方 8 行Emoji pickerpackages/plugin-detail/src/ReactionPicker.tsx:88——role="listbox"弹层{emoji} {count} reaction(s)Close+Close panelpackages/components/src/custom/navigation-overlay.tsx:391-392与 :476改动
page:header的 toolbardetail.pageHeaderActionsdetail.emojiPickerdetail.reactionCount/detail.reactionCountOnecommon.close(复用控制台其余部分已在用的键,不新造)common.closePanel五个新词条十个语言包全补(
all-locales-key-parity强制)。复数项:双 key,不用
_one/_other按正文口径走本仓既有的双 key 约定(
detail.relatedRecords/relatedRecordOne、lookup.recordCount/recordCountOne),⛔ 不引入 i18next 的_one/_other后缀 —— zh/ja/ko 没有独立单数形式,那些包会合理地缺_one那一半,parity 门禁会把它读成丢键。调用点按count === 1显式二选一。navigation-overlay.tsx原本完全没接 i18n,新增了useSafeTranslate,放在所有条件 return 之上(rules-of-hooks)。测试
新增三个测试文件,每处en 正向 + 至少一个非 en 正向 + 英文字面量反向断言;复数项两个 key 各一例(count=3 走复数键,count=1 走
…One键),并特意断言 zh 下两个 key 同形 —— 这正是后缀方案不适用本仓的原因。反向验证(方向为先验预测,非事后解释)
预测:把四处调用点改回英文字面量后,非 en 断言应全红,en 断言应全绿(字面量恰好等于 en 包的值)。实测与预测一致:
10 条失败全部是 zh/ja/es/fr/de 用例,5 条通过全部是 en 用例 —— 四处站点都被真实钉住,没有空断言。
回归面
消费半径已按规则外扫(不只按改动包):
packages/plugin-view/src/__tests__/ObjectView.test.tsx用getByLabelText('Close panel')渲染的正是本组件的分栏模式,packages/components/src/__tests__/page-header-actions.test.tsx:197用正则匹配 toolbar 名 —— 两者无 provider 时走英文 fallback,均仍绿,已实跑确认。一处值得复核的测试写法
抽屉关闭按钮按
title定位,而不是 role+name。shadcnSheet原语自己也会渲染一个关闭按钮,其可访问名是硬编码英文 sr-only 文本(packages/components/src/ui/sheet.tsx:80,No-Touch 区)。NavigationOverlay用[&>button:last-of-type]:hidden把它 CSS 隐藏,真实浏览器里它不在无障碍树上;但 jsdom 不套用 Tailwind,RTL 仍能看到它,于是 en 下getByRole('button', { name: 'Close' })会匹配到两个元素。我们自己的按钮是唯一带title的,按title定位才精确。原语那个未翻译的标签是独立的越界发现,已单独归档,本 PR 不碰。越界发现(均已按 Prime Directive #10 归档为 unassigned issue,本 PR 不修)
Sheet/Dialogprimitives ship a hardcoded EnglishClosesr-only label — every drawer and modal in the console announces it untranslated objectstack#5505 —— shadcnSheet/Dialog原语硬编码英文Closesr-only 标签。约 20 个SheetContent消费方 + 所有DialogContent消费方都会原样渲染(只有NavigationOverlay把它藏了),非 en 会话下全部念英文。修复落在 No-Touch 区,需要路线决策(wrapper / sync 脚本打补丁 / 传 prop),故未在此处顺手改。N items,Resize drawer,Open as full page,Record Detail, CommentThread's reaction tooltip) objectstack#5506 —— 同一扫描半径内另外五处硬编码英文:page:tabs计数徽章的{count} items(同样内建英文复数)、Resize drawer、Open as full page(prop 默认值)、Record Detail(可见标题默认值)、以及packages/collaboration/src/CommentThread.tsx:520的1 reaction/{n} reactionstooltip(与本 PR 修掉的形状完全一致)。Generated by Claude Code