karabiner / EN↔ES translation

One shortcut. Three ways through.

Translate reads the context before choosing a route: replace an editable selection, copy a read-only selection into an accumulating popup, or capture a region and pass its OCR text through the same bilingual handoff.

translate / route console simulation ready
deterministic simulation

This page reads no selection, screen, or clipboard, makes no network request, and writes nothing to your machine.

source / English detectededitable selection
01readselection
02detectEN → ES
03translatenetwork
04replacein place
result / Spanishwaiting

Buenos días. La compilación está lista para revisión.

simulation.ready / fixed example / no machine access

page demo / fixed phrases real tool / Google free endpoint capture + OCR remain local

context chooses the route

The shortcut changes with the surface.

The same invocation checks what is available first. It does not open a generic translator and ask the person to reconstruct the task by hand.

01 / editable selection

Translate and replace

Selected text in an editable field is copied, translated, and pasted back over the original selection. System Events drives the copy-and-paste handoff.

outputreplacement in the source field
02 / selected text

Copy and accumulate

A selection outside an editable field is translated to the clipboard and added to the popup history, leaving the source untouched.

outputclipboard + popup entry
03 / no selection

Capture, read, translate

The shortcut opens a screenshot region, runs local OCR, translates the extracted text, then sends the result to the clipboard and popup.

outputcapture → OCR → clipboard + popup

local work / explicit network edge

The route shows where the text goes.

The macOS selection, screenshot, preprocessing, OCR, clipboard operation, popup history, settings, and exports happen locally. Translation itself uses the free Google Translate endpoint and therefore crosses the network.

capture

Local input

Selection inspection and screenshot capture stay on the Mac. Screenshot mode uses Tesseract after an optional ImageMagick cleanup pass.

translation

Network request

The source text is URL-encoded and sent to the free Google Translate endpoint. Direction is auto-detected between English and Spanish.

delivery

Local result

The translated text returns to the selected field, clipboard, or native popup according to the route selected before the request.

page demonstration

Fixed and inert

The interaction above is a deterministic visual replay. It never calls the endpoint, captures the screen, reads the clipboard, or modifies the page outside the sample.


native popup / accumulating history

A translation can stay in the thread.

The background widget is a small AppKit and WebKit app with no Dock icon and no Hammerspoon dependency. New translations enter through its custom URL scheme and accumulate instead of replacing the previous result.

history

Keep source and result together

Each popup entry retains the original phrase, detected direction, and translated phrase so a sequence can be reviewed as one working set.

export

Leave with usable data

Export the accumulated entries to TXT, Markdown, JSON, or CSV in Downloads rather than copying every translation individually.

persistence

Local settings

Widget settings persist under ~/Library/Application Support/lacuna-translate-widget/. The unsigned app may require a first-run right-click Open.


CLI + shortcut + native widget

Use the narrowest route that fits.

The literal CLI prints only the translated text. The Karabiner script adds context detection and delivery. The optional widget adds a durable working history.

install

Fetch the translation tool

$./install.sh translate

The repository installer fetches this tool without requiring a full checkout of the private automations repository.

literal CLI

Translate a pipe or argument

$translate "good morning"

Use the command directly when no selection, screenshot, replacement, or popup behavior is needed.

requirements

Know the permissions

required
Python 3.9+, Tesseract, jq
optional OCR pass
ImageMagick
replace mode
macOS Accessibility