fix(i18n): make rule category dictionaries reactive to language changes#833
Open
actiontech-bot wants to merge 2 commits into
Open
fix(i18n): make rule category dictionaries reactive to language changes#833actiontech-bot wants to merge 2 commits into
actiontech-bot wants to merge 2 commits into
Conversation
RuleCategoryDictionary and related exports were static module-level
constants that captured t() translations at import time, so switching
the UI language from Chinese to English left category labels ("在线",
"DML", "可维护性" etc.) untranslated.
Root cause: t() was called once during module initialization instead
of on every render. This made the category display language-insensitive
while desc/annotation (fetched from the API per-language) worked fine.
Fix: Convert all dictionary constants to getter functions that call
t() at invocation time; add Proxy-based backward-compatible aliases
so existing imports continue to compile. In useRuleCategories hook,
call getRuleCategoryDictionaryGroup() inside useMemo and add
i18n.language to the dependency array so the memo recalculates when
the user switches language.
Closes CASE-002 (AC-3.2, AC-4.3 regression).
The English locale file was missing the entire `category` section that
exists in zh-CN/rule.ts, causing t('rule.category.tag.*') to fall back
to Chinese text when the UI is in English mode. This made category tags
like "Online", "DML", "DDL", "Maintainability" display in Chinese even
after switching to English.
Added complete English translations for all category fields including
auditAccuracy, auditPurpose, operand, sql, performanceCost, and all
tag entries (online, offline, database, table, column, index, etc.).
Fixes CASE-002 regression-1 failure.
Coverage report
Test suite run success3711 tests passing in 814 suites. Report generated by 🧪jest coverage report action from 396e584 |
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.
Summary
修复 SQLE UI 中 DB2 规则分类(category)在中英文切换时未跟随更新的回归缺陷,配合
sqle-db2-plugin-jIssue #99(DB2 插件 I18n 支持)的端到端联调。Changes
useRuleCategories:将RuleCategoryDictionary等静态导出改为按调用时机执行t()的 getter 函数,并通过 Proxy 提供向后兼容别名;hook 内部把i18n.language加入useMemo依赖,确保语言切换后立即重算。en-US/rule.ts:补全category字段缺失的英文翻译(auditAccuracy / auditPurpose / operand / sql / performanceCost 以及全部 tag 项),消除英文环境下分类标签回退为中文的问题。Related
Test plan