一个支持多词典的翻译插件(目前仅支持单词)

项目已加入 https://hacktoberfest.digitalocean.com/ , 贡献 PR 可以获得 hacktoberfest 积分 :smile:

目前是打算集成

1 个赞

今天发现 etymonline 的网页改版了,然后用到 etymonline 的用户会提示 cl-assert 错了,目前已修复,等待 melpa 更新即可。

如果不在意 etymonline 的错误可以 toggle-debug-on-error 来关闭 debug-on-error,对其他后端的输出无影响,就是会在 echo area 里显示一个错误信息而已。

1 个赞

最近看到go-translate 更新了:

lorniu/go-translate: Powerful translator on Emacs. Supports multiple translation engines such as Google, Bing, deepL. (github.com)

@Youmu 有两个问题请教下:

  1. 能否考虑加入google翻译,go-translate中不需要任何token;
  2. 能否加入cache机制。go-translate明显搜索体验要快很多。

不要token的方式看popweb的实现,通过调用公开网络接口配合动态css隐藏大法,效果好无次数限制。

不过这种技术依赖完整浏览器技术来实现。

go-translate 中对google翻译支持也不需要token。

1 个赞

不是没用token,而是有一个魔法key, 我在 insert-translated-name.el 也是这样么用的。

不过我觉得词典翻译还是要用网络服务才爽, 服务商默认都排好版,还有例句啥的,文本解析后再排版太费精力。

有空可以用一下 popweb 体验一下吧,比EAF轻量级很多,跨平台都支持,很方便。

1 个赞

改天体验下大佬的新作,fanyi 也做得挺好的👍🏻

不是很想加 Google 翻译呀,我倒是更倾向于加 DeepL…

这点的话好像 url-automatic-caching 就可以,让咱试试。

还是得人工来做,url-automatic-caching 只对返回 304 的请求会 cache. 不过如果自己写的话还是可以抄一下 url-cache 的。

加入DeepL也很好啊 :grin: 我更关心cache

我是用 org-capture 了一个模板,遇到任何生词的时候,copy一下,然后按 org-capture 的快捷键,自动帮我加到我的 org 生词本,也非常方便:

(add-to-list 'org-capture-templates '(("w" "New word" entry (file+headline "20220515065323-vocabulary.org" "New")
                                       "* %^{Input the new word:|%c}\n\n%i[[fanyi:%\\1][%\\1]]%?"
                                       :empty-lines 1)))

另外想请问下 @Youmu 能有办法对字典的结果进行排序设定么,比如我想每次让 Longman 的放在最前面,现在好像是哪个先有结果就哪个先放在前面?

2 个赞

这个好像很多人都提了。目前确实是哪个先返回就渲染哪个的,如果想直接跳到 Longman 的那节可以直接用 M-g i (imenu) 呀

学到了,感谢!

话说为什么使用 fanyi-dwim 会添加记录到 fanyi-history,但是使用 fanyi-dwim2 就不添加记录到 fanyi-history 里面呢?是特意设计成这样的吗?

本意不是这样的,我好像忘记将它的结果 push 至 fanyi-history 了… 如果当前光标下有一个单词,那么调用 fanyi-dwim2 会等效于:

(fanyi-dwim "word at point")

因为这样没有经过

(interactive (let* ((default (if (use-region-p)
                                 (buffer-substring-no-properties (region-beginning) (region-end))
                               (thing-at-point 'word t)))
                    (prompt (if (stringp default)
                                (format "Search Word (default \"%s\"): " default)
                              "Search Word: ")))
               (list (read-string prompt nil 'fanyi-history default))))

这一步选词过程,于是就导致没有调用 (read-string prompt nil 'fanyi-history default) 近而就导致了你说的问题。

之前在 arch 上,这个包很好用。后来电脑坏了换了 Mac M1,然后查询就经常没有反应。有时候直接出结果,有时候等好久才出结果。5个结果有时候会返回三个,有时一个。

配置就下面的一个。

(custom-set-variables '(fanyi-providers '(
                                            fanyi-haici-provider
                                            fanyi-youdao-thesaurus-provider
                                            fanyi-etymon-provider
                                            fanyi-longman-provider
                                            fanyi-libre-provider
                                            )))

大佬有没有什么提示,怎么找出问题所在?

这个只能看一下当时发的 http 请求是啥样子的了。以外在 github 上也有一个 issue 比较相似

我的Mac上也是这样。。。

我在 terminal 中使用 curl 试了下,发现返回结果就是很慢。

这个可能得需要您 debug 一下,看是否是 UA 等 http 头的问题。

您好!可否问一下如何清除查询单词的历史记录,我想应该是清除变量【fanyi-history】中的值,但试了『(setq fanyi-history nil)』没有成功。谢谢您的解答。