aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-toot.el17
1 files changed, 17 insertions, 0 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 1d80e55..9c09441 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -70,6 +70,11 @@
(autoload 'mastodon-tl--toot-id "mastodon-tl")
(autoload 'mastodon-toot "mastodon")
+; for mastodon-toot--translate-toot-text
+(autoload 'mastodon-tl--content "mastodon-tl")
+(when (require 'lingva nil :no-error)
+ (declare-function lingva-translate "lingva"))
+
(defgroup mastodon-toot nil
"Tooting in Mastodon."
:prefix "mastodon-toot-"
@@ -278,6 +283,18 @@ Makes a POST request to the server."
(kill-new (mastodon-tl--content toot))
(message "Toot content copied to the clipboard.")))
+(when (require 'lingva nil :no-error)
+ (defun mastodon-toot--translate-toot-text ()
+ "Translate text of toot at point.
+Uses `lingva.el'."
+ (interactive)
+ (if mastodon-tl--buffer-spec
+ (let* ((toot (mastodon-tl--property 'toot-json)))
+ (if toot
+ (lingva-translate nil (mastodon-tl--content toot))
+ (message "No toot to translate?")))
+ (message "No mastodon buffer?"))))
+
(defun mastodon-toot--own-toot-p (toot)
"Check if TOOT is user's own, e.g. for deleting it."
(and (not (alist-get 'reblog toot))