Skip to content

fix(i18n): add WeChat channel i18n support with weixin namespace#1891

Merged
piorpua merged 6 commits intoiOfficeAI:mainfrom
gobylor:Lor/fix/weixin-i18n
Mar 30, 2026
Merged

fix(i18n): add WeChat channel i18n support with weixin namespace#1891
piorpua merged 6 commits intoiOfficeAI:mainfrom
gobylor:Lor/fix/weixin-i18n

Conversation

@gobylor
Copy link
Copy Markdown
Contributor

@gobylor gobylor commented Mar 29, 2026

Summary

  • Add "weixin" i18n namespace (18 keys) to all 6 locale settings.json files (en-US, zh-CN, ja-JP, zh-TW, ko-KR, tr-TR), following the same pattern as lark and dingtalk
  • Replace all hardcoded Chinese fallback strings in WeixinConfigForm.tsx with English equivalents
  • Update test assertions to match new English fallbacks (13/13 tests pass)

Closes #1890

Test plan

  • bun run test — 13/13 WeChat config form tests pass
  • bunx tsc --noEmit — no type errors
  • bun run lint — 0 errors
  • bun run format — clean
  • node scripts/check-i18n.js — all locales complete, validation passes
  • prek run --from-ref origin/main --to-ref HEAD — all CI checks pass
  • Manual: Open Settings > Remote > Channels > WeChat — verify strings are localized per language

gobylor added 3 commits March 30, 2026 00:06
Add 18 i18n keys for WeChat channel configuration UI to all 6 locales
(en-US, zh-CN, ja-JP, zh-TW, ko-KR, tr-TR), following the same nested
namespace pattern as the existing lark and dingtalk blocks.
… config

Replace all Chinese fallback strings in WeixinConfigForm t() calls with
English equivalents, and update test assertions to match. The i18n keys
now resolve to proper translations at runtime via the weixin namespace.
…ions

Apply oxfmt line-wrapping to long t() calls in WeixinConfigForm.
Regenerate i18n-keys.d.ts with 18 new settings.weixin.* keys.
@sentry
Copy link
Copy Markdown

sentry bot commented Mar 29, 2026

Codecov Report

❌ Patch coverage is 55.55556% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/common/utils/utils.ts 50.00% 1 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

gobylor added 3 commits March 30, 2026 00:46
The main process build config suppresses Rollup EVAL warnings, but the
renderer config did not. This caused flaky build failures on CI
(macOS arm64) when eval('require')('crypto') in shared utils.ts was
bundled into the renderer.

Constraint: Must match the existing onwarn pattern in main config (L107-110)
Confidence: high
Scope-risk: narrow
…ypto

The uuid() function used eval('require')('crypto') to load Node.js crypto
without webpack bundling it. This triggered Rollup EVAL warnings in the
renderer build and caused flaky CI failures on macOS arm64.

globalThis.crypto is available in Node.js 19+ and all modern browsers,
so a single code path handles both environments without eval.

Rejected: Keep eval + suppress warning | eval in renderer bundle is unnecessary complexity
Rejected: Conditional import() | async import changes uuid() return type to Promise
Confidence: high
Scope-risk: narrow
Directive: Do not re-introduce eval or dynamic require in shared code — use globalThis.crypto
Add test for the !isGeminiAgent ternary that renders the auto-follow
model label, fixing the partial coverage flagged by Codecov.
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 30, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review:fix(i18n): add WeChat channel i18n support with weixin namespace (#1891)

变更概述

本 PR 为微信 channel 补全了 i18n 支持:向全部 6 个 locale 的 settings.json 添加了 weixin 命名空间(18 个 key),将 WeixinConfigForm.tsx 中所有硬编码中文 fallback 替换为英文,更新了 i18n-keys.d.ts 类型定义,并更新了对应测试断言。顺带将 utils.ts 中的 uuid 函数从多分支 eval/require trick 简化为 globalThis.crypto,同时在 electron.vite.config.ts 中添加了 EVAL 警告抑制。


方案评估

结论:✅ 方案合理

i18n 补全完全遵循了项目现有的 lark/dingtalk 命名空间模式,key 结构一致,所有 locale 完整覆盖。utils.ts 的重构用 globalThis.crypto(Node.js 16.15+/Electron 18+ 均可用)替换了原有的 eval 技巧,代码更简洁、更可维护。方案无设计盲点。


问题清单

🔵 LOW — EVAL 警告抑制原因不清晰

文件electron.vite.config.ts,第 177–180 行

问题代码

onwarn(warning, warn) {
  if (warning.code === 'EVAL') return;
  warn(warning);
},

问题说明utils.ts 中的 eval('require') 已被同步移除,但此 onwarn 却全局抑制了所有来源的 EVAL 警告。如果其他依赖或代码确实存在 EVAL 用法,这里会静默掩盖潜在问题。PR 描述未说明保留此配置的原因。

修复建议:若此 onwarn 是为其他依赖(如某第三方包)所设,建议在注释中说明来源;若 eval 被完全移除后确实没有其他触发源,可考虑一并删除此配置。


🔵 LOW — utils.ts patch 覆盖率不足

文件src/common/utils/utils.ts

问题说明:Codecov 报告显示本次改动的 patch 覆盖率为 50%,utils.ts 有 4 行/分支未被测试覆盖(getRandomValues 路径和 catch fallback 分支)。虽然 codecov/patch 在本项目配置为 informational(不阻塞合并),但覆盖不足说明 getRandomValues 和 fallback 逻辑缺少单元测试用例。

修复建议:在 utils.ts 的现有测试中(若有)或新建测试,补充以下场景:

  • 模拟 globalThis.crypto 仅有 getRandomValues(无 randomUUID)时的行为
  • 模拟 globalThis.crypto 不存在时的 fallback 行为

汇总

# 严重级别 文件 问题
1 🔵 LOW electron.vite.config.ts:177 EVAL 警告抑制原因不明,建议补充注释或移除
2 🔵 LOW src/common/utils/utils.ts uuid 重构后 patch 覆盖率 50%,缺少边界场景测试

结论

批准合并 — 无阻塞性问题,i18n 实现完整规范,utils.ts 重构逻辑正确,仅有两个低优先级改进建议。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1891

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua enabled auto-merge (squash) March 30, 2026 01:23
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
@piorpua piorpua disabled auto-merge March 30, 2026 01:35
@piorpua piorpua merged commit f48300c into iOfficeAI:main Mar 30, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(i18n): WeChat channel config form has hardcoded Chinese strings

2 participants