youdao-dictionary
is a simple Youdao Dictionary (有道词典) interface for Emacs.
Install youdao-dictionary
from MELPA with:
M-x package-install RET youdao-dictionary RET
Youdao discontinued the free API earlier this year (2023), so this package is no longer ready to use out of the box. You will need to apply for an API on your own.
You can set your api key and secret in ~/.authinfo.gpg
or ~/.authinfo
, e.g,
machine openapi.youdao.com login 应用ID password 应用秘钥
Alternatively, you can set them in your config, e.g,
;; Change 应用ID and 应用秘钥 to yours
(setq youdao-dictionary-app-key "应用ID"
youdao-dictionary-secret-key "应用秘钥")
youdao-dictionary-search-at-point
youdao-dictionary-search-at-point+
youdao-dictionary-search-at-point-tooltip
youdao-dictionary-search-at-point-posframe
youdao-dictionary-search-from-input
youdao-dictionary-search-and-replace
youdao-dictionary-play-voice-at-point
youdao-dictionary-play-voice-from-input
youdao-dictionary-posframe-tip-face
tooltip
;; Enable Cache
(setq url-automatic-caching t)
;; Example Key binding
(global-set-key (kbd "C-c y") 'youdao-dictionary-search-at-point)
;; Integrate with popwin-el (https://github.com/m2ym/popwin-el)
;; (push "*Youdao Dictionary*" popwin:special-display-config)
;; Set file path for saving search history
;; (setq youdao-dictionary-search-history-file "~/.emacs.d/.youdao")
;; Enable Chinese word segmentation support (支持中文分词)
;; (setq youdao-dictionary-use-chinese-word-segmentation t)
Notes: A external Chinese word segmentation tool (e.g. 结巴分词) is needed to enable Chinese word segmentation support. For more info, see chinese-word-at-point.el#prerequisite.