msoutopico

mt_deepl.py

May 27th, 2022 (edited)
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import deepl as mt
  2.  
  3. # get api key
  4. api_key_file = "/home/pico/.omegat/keys/deepl_api_key.txt"
  5. with open(api_key_file) as f:
  6.     auth_key = f.read().rstrip()
  7.  
  8. # get translation
  9. translator = mt.Translator(auth_key)
  10. result = translator.translate_text("Hello, world!", target_lang="FR")
  11. print(result.text)  # "Bonjour, le monde !"
Add Comment
Please, Sign In to add comment