fix(plugin-gantt): 快速筛选栏改走 i18n 词条,不再硬编码中文 - #3386
Merged
Merged
Conversation
ObjectGantt 渲染 QuickFilterBar 时把 all/clear/empty/resultSummary 四个
label 直接写成中文字面量,导致 en/ja/es/ar 会话下这一条筛选栏仍是中文,
而甘特图工具栏其余部分正常本地化;同时违反 AGENTS.md 诫条 #-1(英文码库)。
QuickFilterBar 本身无责 —— 它是纯展示组件且已回退英文,是宿主钉死了文案。
四个文案移入新的 gantt.quickFilter 命名空间并补齐十个语言包,调用点改用
plugin-gantt 既有的 useGanttTranslation(与该包其余全部文案同一把 t,
逐键回退,宿主词典缺键时回落到内置英文而非裸键)。resultSummary 刻意保持
单花括号占位符({shown}/{total}):调用点用字面 .replace 替换而非 i18next
插值,与 gantt.autoScheduleDlg.body 一致,也正是 all-locales-key-parity
的 SINGLE 正则已知的约定 —— 改成 {{shown}} 会把占位符原样显示给用户。
Fixes objectstack-ai/objectstack#5427
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#5427
问题
ObjectGantt渲染QuickFilterBar时,把all/clear/empty/resultSummary四个 label 直接写成了中文字面量。两个缺陷叠在一处:en/ja/es/ar会话下这一条筛选栏依然是中文,而甘特图工具栏其余部分本地化正常,反差非常显眼。QuickFilterBar本身无责:它是纯展示组件,且已经回退英文(labels?.clear ?? 'Clear')。是宿主钉死了文案。前提核实
已对
origin/main核实四处硬编码仍在(packages/plugin-gantt/src/ObjectGantt.tsx,call site 位于第 1384 行QuickFilterBar),premise 成立。改动
gantt.quickFilter命名空间,十个语言包全部补齐(all-locales-key-parity全量强制)。useGanttTranslation。关于第二点的取舍:issue 正文建议照
DashboardFilterBar用useSafeTranslate,但ObjectGantt组件内已经持有const { t } = useGanttTranslation();(第 433 行),该包其余四十余条文案统统走它。再引入第二个翻译 hook 会让同一组件里并存两套机制;而useGanttTranslation的语义与useSafeTranslate等价(逐键回退,宿主词典缺键时回落内置英文而非裸键),且英文默认值集中在GANTT_DEFAULT_TRANSLATIONS这一张表里 —— 把这四条散到调用点反而会让"gantt 到底内置了哪些英文"这个问题失去单一答案。因此额外动了useGanttTranslation.ts一个文件(+7 行,登记四条英文默认值);不登记的话,无 Provider 的独立嵌入会把裸键gantt.quickFilter.all显示给用户。gantt.quickFilter.resultSummary刻意保持单花括号占位符({shown}/{total}):调用点用字面.replace替换,不是 i18next 插值,与gantt.autoScheduleDlg.body一致,也正是all-locales-key-parity的SINGLE正则已知的约定。改成双花括号会把占位符原样显示给用户 —— 新增的 parity 测试对十个包逐一钉住了这一点。测试
新增三个文件:
ObjectGantt.quickfilter.i18n.test.tsx—— en / zh 两面,各自带反向字面量断言(en 会话下断言中文四条都不出现;zh 会话下断言英文不泄漏),防硬编码悄悄回来。ObjectGantt.quickfilter.i18n.fallback.test.tsx—— 无 Provider 时回落内置英文,断言绝不出现裸键、占位符必须被替换。单独成文件是必需的:挂过I18nProvider会把 react-i18next 的全局实例留在该语言上,同文件内的"无 Provider"渲染会继承它(实测拿到的是中文而非英文默认值)。gantt-quickfilter-locale-parity.test.ts—— 十包覆盖 + 单花括号拼写 + 非 zh 包不得含被删除的中文字面量。同时给
renderIn显式传了persistLanguage={false}:provider 的 bootstrap 会从 localStorage 读取上次持久化的语言并覆盖defaultLanguage(见resolveBootstrapConfig),不关掉的话 zh 用例会决定 en 用例渲染成什么,变成顺序依赖。反向验证(先定方向再跑):把中文字面量还原回调用点后,预期 en 用例与无 Provider 用例转红、zh 用例仍然绿(硬编码的中文恰好等于 zh 文案)、locale parity 仍然绿(它守的是语言包,不是调用点)。实跑与预期完全一致 —— 这说明 zh 那一面单独存在时抓不到这个缺陷,en 一面才是承重的,两面同时保留是有意义的。
修复态全绿:
changeset已附(patch;按仓库约定不声明 major),check-changeset-no-major.mjs通过。未做的事
QuickFilterBar.tsx第 41/43 行的 JSDoc 注释里仍有中文(/** "全部" / "All" — … */),同属诫条 #-1 但先于本 issue 存在、且与被渲染的文案无关,按"scope = issue"另行记录、不在本 PR 顺手改。🤖 Generated with Claude Code
https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
Generated by Claude Code