The most difficult thing when reading an English dissertation is to copy the sentence for DeepL Translator and then format it every time. .. (?) We have automated the process so that it can be done with a single shortcut key. It is like this. It is intended for Windows.
ClipboardCopyToDeepL.py
import re
import pyperclip
import webbrowser
import urllib.parse
text = urllib.parse.quote(pyperclip.paste(), safe = "|").replace("|", "%5C%7C").replace("%0D", "%20").replace("%0A", "").replace("-%20", "")
webbrowser.open("https://www.deepl.com/en/translator#en/ja/" + text)
(5/27 postscript: After all I decided to use urlLib. For some reason, "|" was "% 5C% 7C" instead of the standard "% 7C", so I changed it separately)
It's pretty simple, but I use pyperclip to retrieve the text on the clipboard and then format it. The rules of plastic surgery are
--Eliminate the -
that enters when English words are separated by line breaks
--Replace line breaks with spaces
only.
Finally, throw a web request to DeepL Translator and you're done.
For DeepL Translator, enter the character string you want to translate at the end of https://www.deepl.com/en/translator#en/ja/
and it will jump to the site where the translation result is displayed, so use that. Did.
Save this script somewhere so that it will be executed when requested in a batch file.
Place the following batch file in the same hierarchy as the python script
"Python execution directory" "python script directory"
For example, if you are using anaconda and place the created script under "ClipboardCopyToDeepL /" on the desktop
ClipboardCopyToDeepL.bat
C:\Users\User name\anaconda3\python.exe C:\Users\User name\Desktop\ClipboardCopyToDeepL\ClipboardCopyToDeepL.py
It becomes.
Create a shortcut for the batch file.
Set the shortcut key
from the shortcut properties.
Click the frame and hit the key you want to assign, and it will be entered without permission.
(Addition: I can use this shortcut by placing it under C: \ ProgramData \ Microsoft \ Windows \ Start Menu \ Programs \
.)
This will make your dissertation easier to read.
Recommended Posts