bamanzi / bamanzi.github.io

0 stars 0 forks source link

GoldenDict tips #3

Open bamanzi opened 2 weeks ago

bamanzi commented 2 weeks ago

GoldenDict

https://github.com/goldendict/goldendict

Dictionary formats supported: https://github.com/goldendict/goldendict/wiki/Supported-Dictionary-Formats

Download (windows only)

Debian/Ubuntu

GoldenDict-NG

(new features: webengine, highdpi, anki_integration, dark theme...)

https://github.com/xiaoyifang/goldendict-ng

Dictionary formats supported: https://xiaoyifang.github.io/goldendict-ng/dictformats/

Download (windows & macos prebuilt)

Debian/Ubuntu

bamanzi commented 2 weeks ago

query word from command line

You can send word to mainwindow to popup via goldendict <word>

https://xiaoyifang.github.io/goldendict-ng/topic_commandline/

what the popup window looks like:

... in emacs

(defun goldendict-current-word ()
  (interactive)
  (let ((sel (if mark-active
                 (buffer-substring (region-beginning) (region-end))
               (buffer-substring
                (car (bounds-of-thing-at-point 'word))
                (cdr (bounds-of-thing-at-point 'word))))))
    (shell-command (concat "nircmd exec show d:\\programs\\goldendict\\goldendict.exe " sel))))

nircmd exec show is necessary (on Windows) to avoid output buffers (as Emacs on windows would wait for GUI application to quit).

bamanzi commented 2 weeks ago

对接有道词典/翻译服务

https://github.com/easeflyer/gd_plugin/tree/master/youdao

  • youdao_get.py get(url)方式调用有道网页翻译接口,经过测试翻译效果非常不错。唯一问题,段落太大时可能翻译不完全。
  • youdao_post.py post 方式调用有道全文翻译接口,比较适合整片文章的翻译。

博客文章: 有道翻译 for GoldenDict Linux 完美屏幕取词插件

FAQ: windows 上运行时显示错误 UnicodeEncode: 'gbk' codec can't encode character ....

解决办法:添加环境变量 PYTHONIOENCODING=utf-8 即可正常工作。详见: https://github.com/easeflyer/gd_plugin/issues/4

注意:在 youdao_get.py中 添加 os.environ['PYTHONIOENCODING']='utf-8' 并不好使

bamanzi commented 2 weeks ago

Firefox 上通过 dict:// 协议对接 GoldenDict

Look up dictionary by using dict:///