Start a new topic

Query DeepL API via Python

Now it's possible to get DeepL's translation directly in CafeTran's target editor, without any screen flickering etc.


Note that the used API is temporarily!


See: https://forum.keyboardmaestro.com/t/translate-via-deepl/7910/2


Thank you very much, Tom!!!


And watch: https://youtu.be/S_AV4K0O2k0


Forgot to say, that you need the uber-useful Keyboard Maestro to execute the macros.


1 person likes this

Absolutely brilliant! Well done, Mr. L!


You always do come up with the most useful stuff! :)


Will


1 person likes this

Will: Absolutely brilliant!


Did you try?


I don't have KM, but I did have a look at the script. As far as I know, using the uber-useful KM won't be successful unless:

  • You installed Python
  • You downloaded the Python script (from where?)
  • Changed some (ab)user-specific links in the macro
Far better would be if the user was told about checking if Python has been installed (how obvious that may seem to be), and if the Python script would have been included in the macro.

And you don't need KM, as usual with rather simple automation.

H.


Addenda: The Python version should be Python3. I don't think it'll run under older versions. And I know where to download the Python script, but I do think it should have been made clear.


H.

Hans, obviously you didn’t read the instructions at the KeyboardMaestro Discourse very well. The source of the Python script is written there and also a download link for the correct Python version. Please do me a favour and refrain from further posting to this thread, in order to keep it readable. Thanks for your kind understanding! PS Be a Sport and consider to remove your incorrect postings.

Thing is, the macro posted here is unusable as is. In other words, it'll have to be adjusted and amended. Besides, it's far more elegant to include the Python script in the macro. And why not?


H.

>Thing is, the macro posted here is unusable as is. // The necessary instructions for modification are detailed in the KBM article. > Besides, it's far more elegant to include the Python script in the macro. And why not? // Because it’s good practice to refer to the original source of the script, perhaps it’ll get updated by the author.

Lenting: Because it’s good practice to refer to the original source of the script, perhaps it’ll get updated by the author


The reference is in the KM entry, not in the script. An update? Apart from how to find out about it, I do hope there's an API by that time.


H.


Hans, Tom has written a comment in the Keyboard Maestro Discourse about how to use the Python script in your beloved solutions, like Automator and AppleScript. Thought that this might interest you ... Have a good Sunday over there in sunny Java.

Lenting: ...your beloved solutions


Beloved solutions? AppleScript and Automator simply come with macOS, just like Terminal, and err, Stickies... No reason not to use them, unless in cases only third party software can solve them or can solve them easier. I'm perfectly sure KM is excellent (no wonder the KM forum is in my RSS fee, and has been there for years), but so far, all the KM macros I've seen for CT, could have been solved by using Automator, AppleScript, and Terminal, and in most cases much easier.


H.


1 person likes this

Updated version, cursor is now positioned in the Target Segment editor and all content is selected prior to inserting the clipboard content:


image


Hi,
I'm doing something similar here, but I paste the results in a Sticky positioned just above CT (and apply a few KBM filters to automatically make a few corrections in the clipboard (for example, replacing English straight apostrophes produced by DeepL with French curled apostrophes, and so on), so I don't have to do it myself.

I also noticed that DeepL proposes again and again the same "wrong translation" (or a translation that I don't like, let's say) for some fragments. I tried to make KBM look for those "wrong translations" in a blacklist file and then signal them in the pasted result (in red characters, for example), but I failed (I might ask for some help on the KBM forum).
It reminds me of an old request for CT, a few years ago: some kind of Blacklist support, so that CT compares the target content with the blacklist file's words (or expressions) and signals them somehow, somewhere (in the Segments grid, for example). That would be very useful...

 some kind of Blacklist support, so that CT compares the target content with the blacklist file's words (or expressions) and signals them somehow, somewhere (in the Segments grid, for example).


Prepare your blacklist in a text file and open it via QA > Word list > Check target segment for words... .


1 person likes this
Thank you Igor,
I'm just adding a link to the solution with KBM, here.
With this, we can check on the fly if a target segment (or a MT proposition) contains words in the blacklist text. Very useful!

1 person likes this
Login to post a comment