Repository navigation
feat(translation): 添加百度翻译和必应翻译支持 - #51
Merged
Merged
Conversation
新增百度开放平台(APP ID + 密钥,MD5 签名、按字节分片、串行限流重试)与必应免费接口(无需密钥、批量请求、实体与换行恢复)两种翻译服务,并在设置页提供服务选项、凭据字段与提示。 缓存键按百度 APP ID 隔离且不改变其他服务的既有缓存;术语表仍只支持 AI 服务。补充提供商单元回归与文档。
Owner
Author
|
审阅记录(非阻塞,供后续迭代):
|
4 tasks done
必应改为直接发送原文,只对出参做一次 HTML 实体解码,避免 `<b>bold</b>` 这类文本被标签对齐器吞词;百度串行队列补约 1 秒间隔,减少 54003 频控重试。 回归补充 54003 重试、请求间隔与原文请求体断言,文档同步。
Owner
Author
|
已按审阅记录处理,提交
验证: |
4 tasks done
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.
解决的问题 / Problem
现有翻译只支持 Google 公开端点与 OpenAI / DeepSeek / 自定义 AI,缺少国内可用的百度翻译和免密钥的必应翻译(#43)。
Fixes #43
分支说明:原
agent/add-baidu-bing-translate-6ac929210abf分支的 PR #44 已被删除,GitHub 拒绝从同名分支重新创建 PR;本 PR 由同一提交(7aaa2ce)的新分支codex/baidu-bing-translate发起,并在其上追加审阅修复893699b,原分支暂时保留。改动后的行为 / Resulting behavior
appid + q + salt + 密钥生成 MD5 签名;按 UTF-8 字节 6000 上限分片,请求串行并保持约 1 秒间隔(标准版约 1 QPS),52001 / 52002 / 54003 退避重试(最多 3 次),保留服务按行返回的换行。edge.microsoft.com免费接口,无需密钥;按 1800 码点分片、最多 40 段 / 20000 字符合批;直接发送原文,恢复换行并对出参 HTML 实体只解码一次;响应条数与请求不符时报无效响应。docs/smart-translation.md与中英文案,回归脚本补充签名、语言映射、分片、批量、实体、54003 重试与请求间隔用例。验证 / Validation
tsc --noEmit通过node scripts/i18n-check.mjs通过vite build通过node scripts/translation-test.mjs、node scripts/glossary-test.mjs、node scripts/translation-manual-test.mjs全部通过/translation:服务下拉包含「百度翻译」「必应翻译」;选百度只显示 APP ID + 密钥,选必应显示免费接口提示,选 AI 仍显示协议 / 地址 / 模型 / 思考强度,控制台无报错。截图受ghCLI 限制未上传。edge.microsoft.com,普通段落、多行段落与长段落均正常;<b>bold</b>现译为<b>粗体</b>,a < b and c > d、AT&T、&均正确保留。数据与兼容性 / Data and compatibility
appId字段;旧设置与备份缺少该字段时归一化为空字符串,向后兼容。提交前检查 / Checklist