1 ;;; emacs-translate.el --- Emacs translate front-end framework supports customize variant translating backends. -*- lexical-binding: t; -*-
2 ;; -*- coding: utf-8 -*-
4 ;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
8 ;; This extension provides a UI front-end for variant translating backends.
15 (defgroup emacs-translate nil
16 "Emacs translate front-end framework supports customize variant translating backends."
17 :prefix
"emacs-translate-"
18 :group
'emacs-translate
)
20 (defcustom emacs-translate-backends-list
'("youdao" "baidu-translate" "bing-translate" "google-translate" "DeepL")
21 "A list of translating backend strings."
24 :group
'emacs-translate
)
26 (defcustom emacs-translate-default-backend
'bing-translate
27 "Specify the default translating backend."
30 :group
'emacs-translate
)
32 (defcustom emacs-translate-mode-map-prefix
(kbd "C-c C-t")
33 "Specify emacs-translate keybindings prefix before loading."
35 :group
'emacs-translate
)
37 (defvar emacs-translate-mode-map
38 (let ((map (make-sparse-keymap)))
40 (global-set-key emacs-translate-mode-map-prefix map
)
41 (define-key emacs-translate-mode-map-prefix
(kbd "t") 'emacs-translate.ui
/translate-at-point
)
42 (define-key emacs-translate-mode-map-prefix
(kbd "r") 'emacs-translate.ui
/translate-region
)
43 (define-key emacs-translate-mode-map-prefix
(kbd "b") 'emacs-translate.ui
/translate-buffer
)
44 (define-key emacs-translate-mode-map-prefix
(kbd "p") 'emacs-translate.ui
/translate-paragraph-by-paragraph-overlay
)
45 (define-key emacs-translate-mode-map-prefix
(kbd "P") 'emacs-translate.ui
/translate-paragraph-by-paragraph-insert
)
46 (define-key emacs-translate-mode-map-prefix
(kbd "C-p") 'emacs-translate.ui
/translate-popup
))
48 "emacs-translate-mode map.")
50 (define-minor-mode emacs-translate-mode
51 "A global minor mode to toggle extension `emacs-translate'."
52 :require
'emacs-translate
54 :lighter
" emacs-translate"
55 :group
'emacs-translate
56 :keymap emacs-translate-mode-map
57 (if emacs-translate-mode
59 (dolist (backend emacs-translate-backends-list
)
60 (require (intern (concat "backend-" backend
)))))))
64 (provide 'emacs-translate
)
66 ;;; emacs-translate.el ends here