Skip to content

Add a Translate window backed by translate-shell - #40

Open
msegoviadev wants to merge 1 commit into
typecraft-dev:mainfrom
msegoviadev:feat/translate-window
Open

msegoviadev wants to merge 1 commit into
typecraft-dev:mainfrom
msegoviadev:feat/translate-window

Conversation

@msegoviadev

Copy link
Copy Markdown

What

A two-pane Translate window for oma-cast. It opens from oma-cast translate [text], the built-in Translate command, the oma-cast:translate shortcut, or IPC. It runs translate-shell locally, so there is no API key and no account.

Translating Hello world! from English to Spanish

Filtering the language list After swapping Spanish and English
Filter the language list Swap with Ctrl+S

Behaviour

  • Source pane with auto-detection through trans -id. A successful detection replaces Auto, so the next translation keeps the same source.
  • Target picker with filtering. Ctrl+L picks the target, Ctrl+Shift+L picks the source. The target is saved in db/settings.json as general.translateTargetLanguage (settings migration 2, default English).
  • Enter translates. Ctrl+S swaps. Super+Enter or Ctrl+Shift+C copies through wl-copy and closes the window. Esc closes it.
  • One translation runs at a time. Detections are serialized, and closing the window cancels both processes.
  • New translate RPC namespace: getTarget, setTarget, translate, cancel. Text is capped at 8000 characters.
  • oma-cast doctor reports whether trans is installed.

Requirements

translate-shell (the trans command) and wl-clipboard. translate-shell sends the text to its own engine, Google by default, so the text leaves the machine. Other engines come from translate-shell's own configuration.

Shortcut

The plugin declares oma-cast:translate. Bind it in ~/.config/hypr/oma-cast.lua:

o.bind("SUPER + SHIFT + T", "oma-cast translate", hl.dsp.global("oma-cast:translate"))

oma-cast setup hyprland adds only the launcher bind, so an existing chord is never overwritten. Super+S opens Omarchy's System menu here, so the swap chord is Ctrl+S.

Notes

  • Shortcut hints in the launcher now use plus signs (Ctrl+K) to match the new window.
  • Docs updated in README.md and CLAUDE.md.
  • node --test tests/*.test.js passes 112 tests, including new coverage for the translate module, language mapping, the settings migration and root-search ordering.

Adds the Translate overlay, the translate RPC namespace, the built-in
Translate command, the oma-cast translate subcommand, and docs. Shortcut
hints use plus signs to match the new window.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant