折腾了好久好久,终于完美破解了谷歌的速率限制和解决了 API 返回的译文相较于网页端质量较低的问题。
目前单个 IP 平均每秒可以翻译 100 条语句。之所以能做到这一点,是因为新的机翻引擎会自动将多条语句合并到一个 HTTP 请求中提交,经由谷歌翻译后再拆解以与原文逐一匹配。实际上 100 条是一个保守值,因为目前会一次提交 4000 个字符,最近几次测试看每次大概可以 200 多条的样子,但是考虑“话别说太满”,所以还是除以二,按保守值算吧。
其次是之前预想的本地术语库纠正机制经过测试,运行的比较完美。
以下随便贴几个翻译的数据(其中每个条目的索引是原始语句,source 中是经过术语库预处理的原文,target 是译文,glossaries 是该原文匹配上的术语):
{
"There are one or more required or recommended plugins to install, update or activate.": {
"source": "There are one or more required or recommended plugins to install, <code>#9687</code> or <code>#22896</code>.",
"target": "需要安装一个或多个必需或推荐的插件,更新或启用。",
"glossaries": {
"22896": "启用",
"9687": "更新"
}
},
"Please contact the administrator of this site for help.": {
"source": "Please contact the administrator of this <code>#43063</code> for help.",
"target": "请联系此站点的管理员寻求帮助。",
"glossaries": {
"43063": "站点"
}
},
"This plugin needs to be updated to be compatible with your theme.": {
"source": "This <code>#43249</code> needs to be updated to be compatible with <code>#16195</code> <code>#56116</code>.",
"target": "此插件需要更新以与您的主题兼容。",
"glossaries": {
"43249": "插件",
"56116": "主题",
"16195": "您的"
}
},
"The remote plugin package does not contain a folder with the desired slug and renaming did not work.": {
"source": "The remote <code>#48813</code> package does not contain a folder with the desired <code>#54859</code> and renaming did not work.",
"target": "远程插件包不包含具有所需别名的文件夹,重命名不起作用。",
"glossaries": {
"48813": "插件",
"54859": "别名"
}
}
}
目前看都能比较好的纠正术语。
目前还差自动从记忆库筛选准确的翻译建议数据这一机制,应该明天可以解决。
之后会封装一个“预翻译”的功能按钮,暂时仅供翻译管理员使用,需要经过一段时间的测试和调优后才能批量应用到整个仓库上。
按目前的进度看,本周应该是可以完成这一块的工作的。