The magic of Google Cloud Translation while you're typing. Anywhere.
Note: gTranslation requires a Google Cloud Translation API-key.
Translate is an extension for Hammerspoon. Once Hammerspoon is installed (see install Hammerspoon below) you can run the following script to install Autocomplete.
$ curl -sSL https://raw.githubusercontent.com/pasiaj/Translate-for-Hammerspoon/master/install.sh | bash
install.sh just clones this repository into ~/.hammerspoon
, loads it into Hammerspoon and sets ⌃⌥⌘T
as the default keybinding.
$ git clone https://github.com/pasiaj/Translate-for-Hammerspoon ~/.hammerspoon/gtranslate
To initialize, add to ~/.hammerspoon/init.lua
(creating it if it does not exist):
local gtranslate = require "gtranslate/gtranslate"
gtranslate.init("YOUR_APIKEY")
Alternatively, copy gtranslate.lua
from this repository to whereever
you keep other Hammerspoon modules and load it appropriately.
Reload the Hammerspoon config.
Hammerspoon can be installed using homebrew/caskroom.
$ brew tap caskroom/cask
$ brew cask install hammerspoon
$ open -a /Applications/Hammerspoon.app
Trigger with the hotkey ⌃⌥⌘T
. Once you start typing, suggestions will populate.
They can be choosen with ⌘1-9
or by pressing the arrow keys and Enter.
Pressing ⌘C
copies the selected item to the clipboard.
The source and target languages and the hotkey can be changed by passing in arguments to
init
call (in your ~/.hammerspoon/init.lua
file)
such as:
gtranslate.init("YOUR_APIKEY", "fi", "en", {"cmd", "ctrl"}, 'L')
This work is almost fully based on the Anycomplete codebase by Nathan Cahill.