added in some comments

main
samerbam 1 year ago
parent ca7996cdbd
commit f21b0ad8d2

@ -3,12 +3,21 @@ from skills.config import deepl_api_key
from skills.config import google_api_key
"""
Reading material for this:
https://www.deepl.com/en/docs-api
https://cloud.google.com/translate/docs/overview
"""
class Translations:
def __init__(self):
self.trigger_phrase = "translate"
# These vars would be good canidates for a future monitoring dashboard
self.total_chars_translated = 0
self.deepl_chars_translated = 0
self.googl_chars_translated = 0 #only increment if successful translation (according to api, it only counts towards the quota if you )
self.googl_chars_translated = 0 #only increment if api charged for the characters (read docs to figure this out)
self.free_monthly_char_limit_googl = 500000
self.free_monthly_char_limit_deepl = 500000
self.supported_deepl_langs = ["list of supported languages"]
@ -24,6 +33,8 @@ class Translations:
def translate_deepl(self, text, language):
self.deepl_chars_translated += len(text)
headers = {
'Authorization': 'DeepL-Auth-Key ' + deepl_api_key,
'Content-Type': 'application/json',
@ -36,8 +47,13 @@ class Translations:
response = requests.post('https://api-free.deepl.com/v2/translate', headers=headers, json=json_data)
return response
def translate_google(self, text, language):
pass #TODO: add in google translate api, probably using python client library for google api
self.google_chars_translated += len(text)
return "" #TODO: add in google translate api, probably using python client library for google api
def translate(self, text):

Loading…
Cancel
Save