Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2022 21:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dridk/1c93e4147183ad39149d5f72e25d1050 to your computer and use it in GitHub Desktop.
Use espanso to translate text with deepl
- regex: ":tr\"(?P<text>.*)\""
replace: "{{translate}}"
- name: translate
type: shell
cmd: "python ~/ \"{{text}}\""
#!/usr/bin/env python
import sys
import deepl
auth_key = "xxxxxxxxx"
translator = deepl.Translator(auth_key)
def translate(word):
result = translator.translate_text(word, target_lang="EN-GB", source_lang="fr")
return result.text
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment