[PYTHON] I want to use shortcut translation like DeepL app on Linux

Introduction

ctrl-c ctrl-c for DeepL apps that can be used on Windows and Mac You can easily translate what you have copied with and read English.

I wanted to do the same with Linux. When I looked it up, there were some things like deepl cli, and I thought I'd make a simple app using this, but now it seems that I can not access the translation results without using the official api of the pro version. So I decided to access it from a browser.

There was a similar thing done by @ masan4444 DeepL Translator on Linux. Just register the shell script in the shortcut. It is easy to use with. (Thank you for your reference.)

But personally,

――I want you to translate in the same tab without opening the tab every time you translate. --I want to easily switch the language of the translation source and translation destination. --I want to translate with a browser different from the browser for browsing.

I wanted to do that, so I made it.

clip-translator https://github.com/kosuke55/clip-translator clip-translator

Install Check the version of google chrome.

google-chrome --version
Google Chrome 81.0.4044.113

Install the chromedriver_binary closest to the version you checked.

sudo pip install chromedriver_binary==81.0.4044.138.0

Install the following packages (PyPI not registered)

git clone https://github.com/kosuke55/clip-translator.git  
cd clip-translator  
sudo pip install -e .  

Setting Search for keyboard and select the shortcuts and custom shortcuts fields.
Press the + button and register the shortcut as shown in the image below. (In the example, ctrl-alt-c is set.)

.

Run From the terminal

clip_translatate_s

Then the browser will be launched.

After the browser is launched, copy the text with ctrl-c and press ctrl-alt-c, and it will be automatically sent to deepl for translation.

Options

clip_translate_s -h
usage: clip_translate_s [-h] [--source SOURCE] [--target TARGET] [--mode MODE]

optional arguments:
  -h, --help            show this help message and exit
  --source SOURCE, -s SOURCE
                        source language (default: en)
  --target TARGET, -t TARGET
                        target language (default: ja)
  --mode MODE, -m MODE  Translation site (deepl or google) (default: deepl)

If you want to use google translate instead of deepL

clip_translatate_s -m google

And.

in conclusion

I feel like I was able to do what I wanted to do for the time being. I will put up with this until the official app comes out.

Recommended Posts

I want to use shortcut translation like DeepL app on Linux
I want to use Linux on mac
I want to use OpenJDK 11 on Ubuntu Linux 18.04 LTS / 18.10
I want to log file I / O on Linux
I want to realize something like AutoHotkey with AutoKey on Ubuntu (Kali Linux)
When you want to use python2.x on modern Gentoo Linux
I want to know how LINUX works!
I want to use jar from python
I want to use IPython Qt Console
I want to develop Android apps on Android
For the time being using FastAPI, I want to display how to use API like that on swagger
I want to use MATLAB feval with python
I want to use Temporary Directory with Python2
I want to use ceres solver from python
I don't want to use -inf with np.log
I want to use ip vrf with SONiC
I want to do pyenv + pipenv on Windows
I want to use the activation function Mish
I want to upload a Django app to heroku
I want to use Python in the environment of pyenv + pipenv on Windows 10
I want to use PyTorch to generate something like the lyrics of Japari Park
I want to be notified when the command operation is completed on linux!
I want to use self in Backpropagation (tf.custom_gradient) (tensorflow)
How to use C216 Audio Controller on Arch Linux
I want to develop an Android application on Android (debugging)
less command I want to definitely remember this [linux command]
I want to find a popular package on PyPi
Preparing to use Ansible on an existing Linux server
I want to AWS Lambda with Python on Mac!
How to use Django on Google App Engine / Python
I want to restart CentOS 8 on time every day.
[Tips] How to use iPhone as webcam on Linux
I want to use the R dataset in python
I want to use Linux commands at the command prompt! Use Linux commands at the command prompt instead of Git Bash
I want to manipulate strings in Kotlin like Python!
I want to do Wake On LAN fully automatically
I want to use Mac / emacs key bindings (keyboard shortcuts) on Ubuntu xkeysnail recommendations
I don't tweet, but I want to use tweepy: just display the search results on the console
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
I want to use the latest gcc without sudo privileges! !!
I want to use R functions easily with ipython notebook
I want to do something like sort uniq in Python
[For beginners] How to use for statements on Linux (variables, etc.)
I want to use only the normalization process of SudachiPy
[Python] I want to use the -h option with argparse
I want to disable interrupts on Raspberry Pi (≒ DI / EI)
I want to announce my graduation thesis on IPython Notebook
I want to use a virtual environment with jupyter notebook!
[AWS EC2] Settings you want to do on Amazon Linux 2
What to do if you can't use WiFi on Linux
I want to use VS Code and Spyder without anaconda! !! !!
Use Github Desktop on Linux
I want to solve Sudoku (Sudoku)
I tried to reintroduce Linux
Use sshpass on Amazon linux2
Use Linux on Windows 10 (WSL2)
How to check and change Linux permissions (permissions) (chmod) (I want to be saved from Permiss on denied)
I want to import Google Keep memos into Bear (memo app)
I want to use a wildcard that I want to shell with Python remove
[Linux] I want to know the date when the user logged in