Skip to main content

Clipboard to translate.

Project description


Translate text from clipboard.


This script is written for Windows. Believe it's a hard way to setup but an easy one to use :).

  1. Python 37 on Windows 10.
  2. Upgrade pip by pip install -U pip.
  3. Install aws-cli from and initiate aws by aws configure.
  4. Install MeCab from Add the /bin directory $PATH.
  5. Make additional dictionary by mecab-ipadic-neologd. Since it's hard to build on Windows 10, I suggest build it on Ubuntu WSL and copy all the files under /usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd into C:\neologd\ if you want the newest dictionary. Here's a pre-built dictionary on 2019-05-11.
  6. NOTICE: We use pydub's ffmpeg binding to play TTS mp3 audio. If you want to enable TTS, download ffmpeg from or just ignore the warning. We won't save mp3 so you should mind of its costs.
  7. Install requirements by pip install -r requirements.txt. If your system default encoding is not UTF-8, you might fail on installing the romkan package. Usually neither chcp nor locale.setdefaultencoding() won't solve this problem. I suggest manually download romkan source code and replace line 12 README = open(os.path.join(here, 'README.rst')).read() to README = open(os.path.join(here, 'README.rst'), encoding="utf-8").read(). Then run python .\ install.
  8. Copy a file of config.ini.example and rename it to config.ini. Fill in the appid and the secretkey, make sure Natural Language Translation of this app is enabled.
  9. Run the script by python .\cp2trans\ or install cp2trans by python install (in this way you can pass step 8).


PS C:\cp2translate> python .\ -h
usage: cp2trans [-h] [--passwd log_file] [-p section] [-l log_file]
                [-e password] [-v {0,1}] [-m pattern] [-n number]
                [-s lang_code] [-t lang_code1,lang_code2,lang_code3] [-d]
                [-i seconds] [-a agth_path] [-o agth_opts]

Clipboard to Translate.

optional arguments:
  -h, --help            show this help message and exit
  --passwd log_file     Change password of an encrypted log_file or
                        encrypt/decrypt log_file and exit.
  -p section, --profile section
                        Load profiled options from the specified section of
                        "config.ini" file. Any other options from command line
                        will be ignored. See details in "config.example.ini".
  -l log_file, --log log_file
                        Save and read translation history from "log_file" to
                        save API calls.
  -e password, --encrypt password
                        Encrypt logfile if you don't want it too exposed ;P.
                        Have to be specified while loading an encrypted log
  -v {0,1}, --voice {0,1}
                        Voice of TTS. "0" for male and "1" for female. Unset
                        for disable TTS.
  -m pattern, --match pattern
                        Only TTS when match <pattern>.
  -n number, --number number
                        Translate only if number of characters less than
  -s lang_code, --source lang_code
                        Source language code. Romkan will only be shown with
  -t lang_code1,lang_code2,lang_code3, --target lang_code1,lang_code2,lang_code3
                        Three target language codes used by youdao, aws and
                        google. Separated by comma.
  -d, --disable         Disable specified translate engine. Corresponding
                        results will be saved as null
  -i seconds, --interval seconds
                        Time interval in seconds to check the clipboard.
  -a agth_path, --agth agth_path
                        Start AGTH text hook. "agth_path" must be specified.
                        You might also have to specify -o option.
  -o agth_opts, --opt agth_opts
                        Extra options passed to "agth.exe". See details by the
                        help button of "agth.exe" window.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cp2trans, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size cp2trans-1.1.0-py3.7.egg (23.3 kB) File type Egg Python version 3.7 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page