Last active
May 16, 2016 16:39
-
-
Save karronoli/6307673927df7082544aa12117bcb224 to your computer and use it in GitHub Desktop.
The interface of "https://translate.google.com/" by MozRepl.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'comint) | |
(require 'url-util) | |
(require 'moz) | |
(defun translate-google (&optional flag) | |
(interactive "P") | |
(let ((lang (if (null flag) "en/ja" "ja/en")) | |
(text | |
(let ((end (if (use-region-p) (region-end) | |
(forward-word) (point))) | |
(start (if (use-region-p) (region-beginning) | |
(backward-word) (point)))) | |
(buffer-substring start end)))) | |
(comint-send-string | |
(inferior-moz-process) | |
(format | |
"content.location.href = \"https://translate.google.com/#%s/%s\"" | |
lang | |
(url-hexify-string text))))) | |
(global-set-key "\C-x\C-t" 'translate-google) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment