fanyi.el
fanyi.el copied to clipboard
Not only English-Chinese translator for Emacs.
fanyi.el
fanyi.el
is a simple yet powerful multi-dictionaries interface for Emacs, currently it includes:
-
海词
-
有道同义词
, Unofficial API -
etymonline
-
Longman
-
LibreTranslate
, Free and Open Source Machine Translation API.
fanyi.el
has integrations with:
-
imenu
, M-x imenu to jump to dictionary section directly. -
bookmark
, C-x r m to make a bookmark for current query word which turnsbookmark
into a vocabulary notebook. -
outline-mode
, TAB to collapse on section. -
ol
(akaorg-link
),org-store-link
on a fanyi buffer, the link can be inserted later viaorg-insert-link
. It's accomplished by introducing afanyi
link type. e.g., C-c C-o on[[fanyi:happy][description of happy]]
will invoke a fanyi search. Sinceol
depends onorg
package, this integration needs an explicit(require 'ol-fanyi)
.
Installation
Install fanyi.el
from MELPA with:
M-x package-install RET fanyi RET
Usage
M-x fanyi-dwim
, or fanyi-dwim2
if you can confirm the word at
point is wanted. A new command fanyi-from-history
is introduced to browse the
search history.
If you want M-x fanyi to list only fanyi-dwim
, fanyi-dwim2
and
fanyi-from-history
, try
;; Emacs 28+
(setq read-extended-command-predicate #'command-completion-default-include-p)
CAUTIOUS: Don't customize fanyi-providers
via setq
, use the custom system instead.
;; If you want English-English dictionary only.
(use-package fanyi
:ensure t
:custom
(fanyi-providers '(fanyi-etymon-provider
fanyi-longman-provider)))
;; Default, comment out the providers you don't need.
(use-package fanyi
:ensure t
:custom
(fanyi-providers '(;; 海词
fanyi-haici-provider
;; 有道同义词词典
fanyi-youdao-thesaurus-provider
;; Etymonline
fanyi-etymon-provider
;; Longman
fanyi-longman-provider
;; LibreTranslate
fanyi-libre-provider)))
;; For non-`use-package' users
(custom-set-variables
'(fanyi-providers '(fanyi-haici-provider
fanyi-youdao-thesaurus-provider
fanyi-etymon-provider
fanyi-longman-provider
fanyi-libre-provider)))
By default, M-x fanyi-dwim
will move the point to the new created *fanyi*
buffer.
(setq fanyi-auto-select nil)
to keep the point.
For windows users,
(setq fanyi-sound-player-support-https t)
if your sound player can be launched with your-sound-player url
. Otherwise it will be called like your-sound-player - <(the voice file)
, where -
is interpreted as stdin
which is an UNIX convention.
FAQ
-
Audio button icon displayed in tofu. The icon is emoji, install the proper font to display it. If you use archlinux,
yay -S ttf-symbola
without additional settings. For MacOS users, add the following elisp to your Emacs config.;; "Apple Color Emoji" is bundled with MacOS. ;; ;; Emacs 29, 28 (set-fontset-font t 'emoji (font-spec :family "Apple Color Emoji") nil 'prepend) ;; Emacs 27 (set-fontset-font t 'symbol (font-spec :family "Apple Color Emoji") nil 'prepend)
-
Longman throws an
user-error
It's expected. File an issue please.
Screenshots