LoginSignup
38
38

More than 5 years have passed since last update.

google-translate.el と popwin.el で翻訳作業が捗った件

Last updated at Posted at 2013-06-13

できるようになること

英語の文字列を選択して C-x C-t したら日本語訳が表示される。

環境など

Ubuntu 13.04 と Mac OS X Lion 上の Emacs 24.3 で確認しました。

設定

google-translate.el と popwin.el をインストールします。
どちらも package.el でインストールできるのでそれで。

M-x package-install google-translate
M-x package-install popwin

インストールできたら、次のように設定を書きます。

;; google-translate.el
(require 'google-translate)

;; キーバインドの設定(お好みで)
(global-set-key [(C x) (C t)] 'google-translate-at-point)

;; 翻訳のデフォルト値を設定(en -> ja)
(custom-set-variables
  '(google-translate-default-source-language "en")
  '(google-translate-default-target-language "ja"))

;; popwin.el
(require 'popwin)
;; おまじない(よく分かってない、、)
(setq display-buffer-function 'popwin:display-buffer)
;; ポップアップを画面下に表示
(setq popwin:popup-window-position 'bottom)

;; google-translate.elの翻訳バッファをポップアップで表示させる
(push '("*Google Translate*") popwin:special-display-config)

これで英文を選択して C-x C-t したら日本語訳がポップアップで表示されるようになります。
ポップアップした翻訳バッファにフォーカスが移ってるので、そのまま訳文をコピーしてもとのバッファに戻ってペーストしたりするといいと思います(そのとき翻訳バッファは勝手に閉じるので邪魔にならない!)。

課題・問題点など

  • 訳文をいちいちコピペするのが面倒なので、直接いまのバッファのカーソル位置に挿入したい。
  • デフォルトの翻訳言語を設定したせいか、他の言語が選べなくなった気がする。

参考ページ

38
38
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
38
38