Skip to content

Instantly share code, notes, and snippets.

@kazuph
Created June 18, 2025 07:35
Show Gist options
  • Save kazuph/6001d0f18188df506329e0bffcd2738b to your computer and use it in GitHub Desktop.
Save kazuph/6001d0f18188df506329e0bffcd2738b to your computer and use it in GitHub Desktop.
Alfred workflow for translating text using plamo-translate

Plamo Alfred Workflow

Alfred workflow for translating selected text or clipboard content using plamo-translate.

Features

  • Translate selected text with hotkey Cmd+Shift+T
  • If no text is selected, automatically uses clipboard content
  • Translation result is copied directly to clipboard (clean output)
  • Visual feedback with Large Type display
  • Audio feedback on completion

Requirements

Setup

  1. Install plamo-translate:

    pip install plamo-translate
  2. Import the workflow into Alfred

  3. Configure hotkey if needed (default: Cmd+Shift+T)

Usage

  1. Select text and press Cmd+Shift+T, or
  2. Copy text to clipboard and press Cmd+Shift+T without selection
  3. Translation result will be copied to clipboard

Workflow Configuration

  • Bundle ID: com.kazuph.plamo-translate
  • Hotkey: Cmd+Shift+T
  • Actions: Script → Large Type → Sound notification
  • Creator: @kazuph
#!/bin/bash
# plamo-translate path
PLAMO_TRANSLATE="/Users/kazuph/.local/share/mise/installs/python/3.12.8/bin/plamo-translate"
# Check if plamo-translate exists
if [ ! -f "$PLAMO_TRANSLATE" ]; then
echo "Error: plamo-translate not found at $PLAMO_TRANSLATE" | pbcopy
exit 1
fi
# Get selected text from command line argument
selected_text="$1"
# Check if we have text, if not try clipboard
if [ -z "$selected_text" ]; then
selected_text=$(pbpaste)
if [ -z "$selected_text" ]; then
echo "Error: No text selected and clipboard is empty" | pbcopy
exit 1
fi
fi
# Copy status to clipboard first
echo "Translating: $selected_text" | pbcopy
# Translate using plamo-translate
result=$("$PLAMO_TRANSLATE" --input "$selected_text" 2>&1)
exit_code=$?
if [ $exit_code -eq 0 ]; then
# Success: Copy translation result to clipboard
echo "$result" | pbcopy
else
# Error: Copy error message to clipboard
echo "Translation failed for: $selected_text
Error: $result" | pbcopy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment