(defun my-translate-dwim (func-region func-string func-buffer)
"My custom function to use translate functions depend on situations."
;; TODO: make this function more portable, let custom function like
;; `babel-region' replace with variable, symbol etc.
(interactive)
(defalias-maybe 'translate-dwim-region func-region)
(defalias-maybe 'translate-dwim-string func-string)
(defalias-maybe 'translate-dwim-buffer func-buffer)
;; region
(if (region-active-p)
(translate-dwim-region (region-content)))
(if (yes-or-no-p "buffer(n) / interactive input (y)")
;; interactive input
;; FIXME: wrong type string, nil
(let ((msg (interactive "sTranslate phrase: ")))
(translate-dwim-string msg))
;; buffer
(translate-dwim-buffer)
)
)
(define-key dictionary-map (kbd "t")
(lambda ()
(my-translate-dwim 'babel-region 'babel-as-string 'babel-buffer)))