3.2 KiB
Current Situation
GoldenDict offered a functionality to translate the word under cursor on Windows in the past, but the technique used there is old and does not work crossplatformly.
However, any OCR program that allow you to set "after capturing action" can be easily used in conjunction with GoldenDict.
Capture2Text release
A few examples are provided below, but there are many options:
Capture2Text
Capture2Text can call executable after capturing, and you can set the executable to GoldenDict.
Detailed usage document: Capture2Text
For example, change the Output action Call Executable
to path_to_the_GD_executable\GoldenDict.exe "${capture}"
Then press Win+Q and select a region. After capturing a word, Capture2Text will forward the word to GoldenDict. If GoldenDict's scanpopup is enabled, it will show up.
The hotkeys can be configured:
Capture2Text can also obtain word near cursor without selecting a region via the "Forward Text Line Capture" by pressing Win+W
you may want to enable "First word only" so that only a single word would be captured
Use Capture2Text on Linux
Capture2Text does not have Linux version, but I have ported it to Linux https://github.com/xiaoyifang/Capture2Text thanks to Capture2Text Linux Port and sikmir.
Shortcuts.app & Apple's OCR
Enable the Clipboard monitoring of GoldenDict, then create a "Shorcut" that will interactively take screnshot and change the clipboard.
You may also add additional capiblities like only getting the first word
Tesseract via command line
On Linux, you can combine command line screenshot then pass the output image to Tesseract then pass the text result to goldendict
Example with spectacle (KDE) and grim (wayland/wlroots)
#!/usr/bin/env bash
set -e
case $DESKTOP_SESSION in
sway)
grim -g "$(slurp)" /tmp/tmp.just_random_name.png
;;
plasmawayland | plasma)
spectacle --region --nonotify --background \
--output /tmp/tmp.just_random_name.png
;;
*)
echo "Failed to know desktop type"
exit 1
;;
esac
# note that tesseract will apppend .txt to output file
tesseract /tmp/tmp.just_random_name.png /tmp/tmp.just_random_name --oem 1 -l eng
goldendict "$(cat /tmp/tmp.just_random_name.txt)"
rm /tmp/tmp.just_random_name.png
rm /tmp/tmp.just_random_name.txt