This script translates the content of the clipboard from English to German if it is in English language and vice versa. This is done by detecting a double press of Ctrl+C (within 0.5 seconds) and copying the translation back to the clipboard. The script uses the DeepL API for the translation.
- Start the script with
python3 clipboard_translator.py
- Copy some text to your clipboard (e.g. by selecting it and pressing Ctrl+C).
- Press Ctrl+C twice in a row. The script will translate the text from English to German and copy the result to the clipboard and also automatically Pastes it if possible.
- Install Python 3.
- Install the required packages with
pip install deepl pynput clipboard langdetect
(orpip3
instead ofpip
). - Create a .env file to save your API_KEY only locally.
- Get a free DeepL API Key by signing up for a DeepL Pro account here.
- Copy the API Key from the DeepL Pro Account Page into the
API_KEY
variable in the .env file.
API_KEY=your_api_key_as_displayed_by_DeepL
- Start the script with
python clipboard_translator.py
- Copy some text to your clipboard (e.g. by selecting it and pressing Ctrl+C). -> You`re already doing this by double tapping Ctrl+C twice
- Press Ctrl+C twice in a row. The script will translate the text from the detected language to English or if detected English to German and copy the result to the clipboard.
- Press Ctrl+V to paste the translation somewhere.
This was created by the help of GPT-4 by OpenAI