A lightweight, discreet Python utility that translates text directly from your clipboard using Google Translate. Perfect for students, researchers, or anyone who needs quick translations without switching between applications.
- 🚀 Instant Translation: Translates clipboard content with a single keystroke
- 🔄 Auto-detect Source Language: Automatically detects the input language
- ⚙️ Configurable: Easy-to-modify settings file for target language preferences
- 🤫 Discreet Operation: No visible UI - works silently in the background
- 📋 Seamless Workflow: Results are automatically copied back to clipboard
- Copy any text to your clipboard
- Trigger the script (via keyboard shortcut)
- The translated text automatically replaces your clipboard content
- Paste anywhere you need the translation
Linux (Ubuntu/Debian):
sudo apt-get install xclipLinux (Fedora/RHEL):
sudo dnf install xclipmacOS:
# xclip not needed on macOS-
Clone the repository:
git clone https://github.com/ha1fdan/clipboard-translator.git cd clipboard-translator -
Install Python dependencies:
pip install -r requirements.txt
-
Configure your preferences (optional): Edit
settings.confto set your preferred target language:DESTINATION_LANG=de # German (change to your preferred language code) SRC_LANG=auto # Auto-detect source language
Common language codes you can use in settings.conf:
| Language | Code |
|---|---|
| English | en |
| German | de |
| French | fr |
| Spanish | es |
| Italian | it |
| Portuguese | pt |
| Russian | ru |
| Japanese | ja |
| Chinese (Simplified) | zh |
| Korean | ko |
For a complete list of supported languages, run:
from googletrans import LANGUAGES
print(LANGUAGES)python main.pySetting up a keyboard shortcut makes the tool much more convenient:
- Open Settings → Keyboard → Keyboard Shortcuts
- Click + to add a custom shortcut
- Name:
Clipboard Translator - Command:
/usr/bin/python3 /path/to/clipboard-translator/main.py - Shortcut: Choose your preferred key combination (e.g.,
Ctrl+Shift+T)
Refer to your desktop environment's documentation for setting up custom keyboard shortcuts.
Use AutoHotkey or similar tools to bind the script to a keyboard shortcut.
Use Automator or Alfred to create a keyboard shortcut.
- Copy text: Select and copy text like
"Hello, how are you?" - Press shortcut: Hit your configured keyboard shortcut (e.g.,
Ctrl+Shift+T) - Paste translation: The clipboard now contains
"Hallo, wie geht es dir?"(if translating to German)
"ModuleNotFoundError: No module named 'googletrans'"
pip install googletrans==4.0.0-rc1"ModuleNotFoundError: No module named 'pyperclip'"
pip install pyperclipLinux clipboard issues:
- Make sure
xclipis installed - Try running
xclip -versionto verify installation
Translation not working:
- Check your internet connection (Google Translate API requires internet)
- Verify language codes in
settings.confare valid
To see what's happening, you can modify main.py to add debug output:
print(f"Original text: {text_to_translate}")
print(f"Translated text: {translated_text}")googletrans==4.0.0-rc1- Google Translate API wrapperpyperclip- Cross-platform clipboard access
This tool uses the unofficial Google Translate API. For production use or high-volume translations, consider using the official Google Cloud Translation API.
Made with ❤️ for seamless translation workflows