EmacsでGoole翻訳(英語・ドイツ語・日本語)を使う (Ubuntu 24.04)
ドイツ語の勉強を始めたので、(三日坊主に終わるかも・笑)
Emacsで使っていた Google翻訳-elisp をリニューアルした。
MELPAから google-translate.el をインストール
これは、もうすでにインストールしてある。
Google翻訳(Emacs Lisp)のインストール
“emacs google translate” で検索すると、atykhonovさんのgithubページがヒットした。
そのページの説明を読んでみると、使えそうな感じなので、インストールしてみた。
$ cd ~/.emacs.d
$ git clone https://github.com/atykhonov/google-translate.git
init.el に以下を記述
2ヶ国語を使う場合は、”google-trandlate-default-ui.el” を使うみたい。
僕は3ヶ国語なので、”google-translate-smooth-ui.el” を使う。
;;;==================================================
;;; google-translate
;;; https://github.com/atykhonov/google-translate/tree/master
;;;
(add-to-list 'load-path "~/.emacs.d/google-translate")
(require 'google-translate)
(require 'google-translate-smooth-ui)
(global-set-key "\C-ct" 'google-translate-smooth-translate)
(setq google-translate-translation-directions-alist
'(("de" . "ja") ("ja" . "de") ("en" . "ja") ("ja" . "en")))
使い方
ドイツ語の場合
Emacsのバッファで 例えば
Hölle
と記述して、Ctrl+t とすると、ミニバッファに
[German > Japanese] Translate: Hölle
と表示される。Enterキーを押下すると、Google Translateバッファが開いて
Translate from German to Japanese:
Hölle
地獄
と表示される。
英語の場合
hell
と記述して、Ctrl+t とすると、ミニバッファに
[German > Japanese] Translate: hell
と表示されるので、Ctrl+n とすると、ミニバッファの表示が順に切り替わり、
[English > Japanese] Translate: hell
という表示に切り替わったところで、Enterとすると、
Translate from English to Japanese:
hell
地獄
名詞
1. 地獄 (hell)
2. ヘル (hell)
3. 奈落 (hell, Hades, theater basement)
4. 魔界 (hell, world of spirits)
DEFINITION
名詞
1. a place regarded in various religions as a spiritual realm of evil and suffering, often traditionally depicted as a place of perpetual fire beneath the earth where the wicked are punished after death.
"irreligious children were assumed to have passed straight to the eternal fires of hell"
感嘆詞
1. used to express annoyance or surprise or for emphasis.
"oh, hell—where will this all end?"
と表示される。(英語の方が充実してるなあ)
これは、便利だ!
参考
google-translate Andrii Tykhonov さん、ありがとうございます。
カテゴリー: Emacs, memo, Ubuntu
タグ: 3カ国語, Google-Translate, google翻訳, ドイツ語, 翻訳
カウント: 55