1 ;;; ui.el --- Provides UI framework for translating. -*- lexical-binding: t; -*-
2 ;; -*- coding: utf-8 -*-
4 ;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
12 (defun emacs-translate.ui
/translate-at-point
(&optional backend
)
14 (if current-prefix-arg
15 (setq backend
(intern (completing-read "Select emacs-translate.el translating backend: "
16 emacs-translate-backends-list
))))
17 (if-let ((text (thing-at-point 'word
)))
18 (emacs-translate.core
/translate text backend
)
19 (error "Nothing at point.")))
21 (defun emacs-translate.ui
/translate-region
(&optional backend
)
23 (if current-prefix-arg
24 (setq backend
(intern (completing-read "Select emacs-translate.el translating backend: "
25 emacs-translate-backends-list
))))
27 (let ((text (buffer-substring-no-properties (region-beginning) (region-end))))
28 (emacs-translate.core
/translate text backend
))
29 (error "No region selected!")))
31 (defun emacs-translate.ui
/translate-buffer
(&optional backend
)
33 (if current-prefix-arg
34 (setq backend
(intern (completing-read "Select emacs-translate.el translating backend: "
35 emacs-translate-backends-list
))))
36 (if-let ((text (buffer-substring-no-properties (point-min) (point-max))))
37 (emacs-translate.core
/translate text backend
)
38 (error "Buffer is empty!")))
40 (defun emacs-translate.ui
/translate-paragraph-by-paragraph-overlay
(&optional backend
)
42 (if current-prefix-arg
43 (setq backend
(intern (completing-read "Select emacs-translate.el translating backend: "
44 emacs-translate-backends-list
))))
47 (defun emacs-translate.ui
/translate-paragraph-by-paragraph-insert
(&optional backend
)
49 (if current-prefix-arg
50 (setq backend
(intern (completing-read "Select emacs-translate.el translating backend: "
51 emacs-translate-backends-list
))))