The DeepL API can be accessed using several client libraries or by a HTTP request.
I’d like to replace the whole draft (if no text is selected) or the selected text with the translation from DeepL.
Can someone please give me guidance on how to build such a request from Drafts and how to read out the response?
"text": "Hallo, Welt!"
@tomtjes’ pointers are the right direction, generally. Drafts can make HTTP requests with it’s scripting interface. Do you have experience scripting access to APIs in general? The
HTTP object works nicely with JSON-based APIs, and will even parse the result for you.
As far as the integration on Drafts’ end, the
editor object (docs) has methods to get the selected text to pass to the API call, and to update it once you have received and parsed a result.
I created an Action that uses the DeepL API for translation → DeepL Translate
Let me know if that is what you wanted Thanks for the inspiration
Thanks for your great work. Once the script is finished, it all looks very straightforward to me, a non-programmer