diff options
author | mousebot <mousebot@riseup.net> | 2022-03-10 13:14:11 +0100 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2022-03-10 13:14:11 +0100 |
commit | b1318ba12165d59cc1b7ce21d3b77099a3ff78d3 (patch) | |
tree | 0cd3f3dec2ada32e3c2f30d88094231d11042913 /lisp | |
parent | a14ecfce170e82ae610247b8ed1854077deed8c0 (diff) |
translate toot with lingva.el
this could easily be made into a macro supporting any emacs translation pkg
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-toot.el | 17 |
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)) |