Skip to content

Text Editor Integration

最上川 edited this page Feb 22, 2020 · 5 revisions

trans is a command-line program which can be easily integrated with any text editor. Below are some useful tips.

Feel free to add to the list if you have done amazing things integrating Translate Shell with your favorite editor. (Vim scripts, Emacs modes, Atom packages, Sublime Text plugins, or anything else!)

GNU Emacs

Front-end of Interactive Shell

You can, of course, use Emacs as a front-end of the Interactive Translate Shell, in the same way you emulate your favorite shell with M-x shell. There is a shortcut for starting Emacs with an interactive Translate Shell session:

$ trans -emacs

Translate on the Fly

When editing a text file, viewing the translation of a region is just one single command: (translating to Japanese, for example)

M-| trans :ja

Minor Mode

There is a (really) simple minor mode for Emacs google-translate-mode.el which you may use as a starting point.

  • C-c - Show translation of the current word in message buffer.
  • C-c = View verbose translation of the current word in popup dialog.
  • C-c + Insert translation of the current word after the current position.

Vim

Plugins

  • translate-shell.vim is a power and flexible plugin for translating text without leaving Vim. It provides a window that displays the translate of word under cursor, selected text or you can use "on fly" translation and translate inserted text.

translate-shell.vim screencast

  • vim-translator is an asynchronous translating plugin for Vim/Neovim, it allows users to use multiple engines including trans

Translate on the Fly

Add this line to your ~/.vimrc: (translating to Japanese, for example)

set keywordprg=trans\ :ja

Use Shift-K to view the translation of the word under the cursor.