External Calls
Saladict provides a complete HTTP interface for integration with other software. You can call Saladict by sending HTTP requests to 127.0.0.1:port
, where port
is the listening port of Saladict, default to 60606
, and can be changed in the app settings.
API Docs:
POST "/" => Translate given text (body is text to translate)
GET "/config" => Open settings
GET "/translate" => Translate given text (same as "/")
GET "/selection_translate" => Translate selected text
GET "/input_translate" => Open input translation
GET "/ocr_recognize" => Perform OCR on screenshot
GET "/ocr_translate" => Perform translation on screenshot
GET "/ocr_recognize?screenshot=false" => OCR without taking screenshot
GET "/ocr_translate?screenshot=false" => Translate screenshot without taking screenshot
GET "/ocr_recognize?screenshot=true" => OCR with screenshot
GET "/ocr_translate?screenshot=true" => Translate screenshot
Example:
Call translation by selection:
To call Saladict's translation by selection, simply send a request to
127.0.0.1:port
:E.g. using curl:
bashcurl "127.0.0.1:60606/selection_translate"
OCR without internal screenshot
This allows you to perform OCR/translation without using Saladict's internal screenshot, so you can use your own screenshot tools. It also solves the problem where Saladict's internal screenshot doesn't work on some platforms.
Workflow:
- Take screenshot using other tool
- Save screenshot to
$CACHE/allen.town.focus.saladict/pot_screenshot_cut.png
- Send request to
127.0.0.1:port/ocr_recognize?screenshot=false
to call
INFO
$CACHE
is the system cache dir, e.g. C:\Users\{username}\AppData\Local\allen.town.focus.saladict\pot_screenshot_cut.png
on Windows.
Example
OCR using Flameshot on Linux:
rm ~/.cache/allen.town.focus.saladict/pot_screenshot_cut.png && flameshot gui -s -p ~/.cache/allen.town.focus.saladict/pot_screenshot_cut.png && curl "127.0.0.1:60606/ocr_recognize?screenshot=false"
Existing Usages (Quick selection translation)(Recommended)
Effect display
SnipDo (Windows)
- Download and install SnipDo in the Microsoft Store
- Download the SnipDo extension of Saladict from the Latest Release (Saladict.pbar)
- Double click the downloaded file to install it.
- Selection some text, you can see the Saladict icon in the upper right corner of the selection, click the icon to translate.
PopClip (MacOS)
- Download and install PopClip in the App Store
- Download the PopClip extension of Saladict from the Latest Release (Saladict.popclipextz)
- Double click the downloaded file to install it.
- Enable the Saladict extension in PopClip settings, and then you can translate by selecting text.
Starry (Linux)
INFO
Starry is still in the development stage, so you can only compile him manually
Github: ccslykx/Starry