Skip to content

fix(translation): 必应发送原文,并为百度请求补上 1 秒间隔 - #52

Closed
cursor[bot] wants to merge 1 commit into
codex/baidu-bing-translatefrom
cursor/unspecified-issue-2934
Closed

cursor[bot] wants to merge 1 commit into
codex/baidu-bing-translatefrom
cursor/unspecified-issue-2934

Conversation

@cursor

@cursor cursor Bot commented Nov 7, 2026

Copy link
Copy Markdown

解决的问题 / Problem

跟进 #51 的审阅记录:

  1. 必应请求先把 &、<、> 转成 HTML 实体。服务端不会总是还原,含尖括号的正文会被截断(例如 <b>bold</b> 被吞成 b)。
  2. 百度串行队列只保证不并发,没有 1 秒间隔。标准版 1 QPS 下连续请求常先收到 54003,再靠退避重试。

必应免费接口非公开、可能失效,界面与文档已有说明;本次不改这一点。没有百度 APP ID / 密钥,未做真实账号请求。

改动后的行为 / Resulting behavior

  • 必应请求体发送原文。响应仍只做一次 HTML 实体解码,服务端已经还原的尖括号标签保持原样。
  • 百度相邻请求的开始时间至少相隔 1 秒;取消发生在这段等待里时不发出下一请求。请求本身耗时超过 1 秒时,下一次不再额外等待。
  • 无界面改动。

验证 / Validation

  • 类型检查 / Type check: pnpm exec tsc --noEmit 通过
  • 文案检查 / i18n check: pnpm run i18n:check 通过
  • 前端构建 / Frontend build: pnpm build 通过
  • Rust 测试(如适用)/ Rust tests (if applicable): 不涉及,未改 Rust
  • 手动验证 / Manual verification: node scripts/translation-test.mjs 通过,覆盖必应原文请求体、实体只解码一次、百度分片间隔与间隔内取消。未打开界面:设置页无改动。未直连必应或百度。

数据与兼容性 / Data and compatibility

不改持久化格式。缓存键仍按原文计算;若已用旧必应请求把含尖括号的段落译错并写入缓存,需要重新翻译才会更新。

提交前检查 / Checklist

  • 已阅读 CONTRIBUTING.md 与 AGENTS.md / I read CONTRIBUTING.md and AGENTS.md.
  • 仅包含本次任务相关文件 / Changes are limited to this task.
  • 已更新相关文档与中英文文案(如适用)/ Relevant docs and both locales are updated where applicable.
  • 已完成适用检查,并说明未验证的部分 / Applicable checks are complete and unverified parts are explained.
Open in Web View Automation 

必应不再把 &、<、> 转成实体后再请求,避免尖括号正文被截断;响应仍只解码一次实体。
百度串行队列在相邻请求开始前至少等待 1 秒,减少标准版 1 QPS 下的 54003。

Co-authored-by: zilorn <[email protected]>
@zilorn zilorn closed this Nov 7, 2026
@zilorn
zilorn deleted the cursor/unspecified-issue-2934 branch November 8, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants