Put your cursor in any French text field, press Ctrl+T, and the whole field
is instantly replaced by the English translation — in place, in any app, with no
visible selection.
Works everywhere: your browser (any web field), Mail, Slack, Notion, a note… The translation runs on a local LLM on your Mac (private, offline, free) via Ollama, with a free online fallback if Ollama isn't set up.
If you write in French but often need to send in English, round-tripping through a translation site is tedious. This makes it a single keystroke, right where you type — no window switching, no copy-paste dance.
Cursor in a French field → press Ctrl+T
│
▼
Read the whole field value (Accessibility API; clipboard fallback)
│
▼
Translate locally with Ollama (qwen2.5:3b) — private, ~1s
│
▼
Write English back via the Accessibility API (no selection, no flash;
paste fallback for apps that don't expose their field value)
Three small pieces:
| Piece | Role |
|---|---|
Ollama + a small model (qwen2.5:3b) |
local, private translation engine |
bin/translate.sh |
FR→EN via Ollama's HTTP API; MyMemory fallback |
| Hammerspoon config | the global Ctrl+T hotkey + read/replace logic |
- macOS (Apple Silicon recommended)
- Homebrew
- The installer pulls the rest: Hammerspoon, Ollama, and the model.
git clone https://github.com/benjaminb10/hotkey-translate.git
cd hotkey-translate
./install.shThen:
- Add this line to
~/.hammerspoon/init.lua:(adjust the path to wherever you cloned it)dofile(os.getenv("HOME") .. "/hotkey-translate/hammerspoon/translate.lua")
- Launch Hammerspoon and grant it Accessibility (System Settings → Privacy & Security → Accessibility → add Hammerspoon) — this is required to read the selection and paste the result. Then click the Hammerspoon menu-bar icon → Reload Config.
Put your cursor in any French text field, press Ctrl+T. A brief
🌐 Translating… appears, then the whole field is replaced by the English — no
manual selection, no visible highlight.
- Hotkey — edit
HOTKEY_MODS/HOTKEY_KEYat the top ofhammerspoon/translate.lua. - Model / quality vs. speed — set
OLLAMA_MODEL(e.g.qwen2.5:7bfor higher quality, a 3B for speed).bin/translate.shreads it. - Languages — the prompt in
bin/translate.shtargets French → English; change it there for other pairs.
With Ollama, the text never leaves your Mac — no key, no account, offline. The
online MyMemory fallback is only used if Ollama isn't reachable; disable it by
removing the fallback block in bin/translate.sh if you want strictly local.
Ctrl+Toverrides the rarely-used Cocoa "transpose characters" binding.- Some apps expose selected text poorly; the clipboard fallback covers most.
- Quality is whatever the chosen local model gives (
qwen2.5:3bhandles idioms like « sans faute » → "without fail" well).
- Hammerspoon — the macOS automation glue
- Ollama + Qwen2.5 — the local translation engine
- MyMemory — free online fallback