Skip to content

Commit

Permalink
#3 changed translation service
Browse files Browse the repository at this point in the history
  • Loading branch information
emregeldegul committed Nov 13, 2020
1 parent 787e922 commit e5c81fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
certifi==2019.9.11
chardet==3.0.4
idna==2.8
requests==2.22.0
googletrans==3.0.0
urllib3==1.25.3
xerox==0.4.1
14 changes: 7 additions & 7 deletions tfc/tfc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .notify import Notify
from .translate import Translate
from googletrans import Translator

from json import loads
from time import sleep
Expand All @@ -9,7 +9,7 @@ class Translation():
def __init__(self, config):
self.config = config

self.translate = Translate(self.config)
self.translate = Translator()
self.notify = Notify()

def start(self):
Expand All @@ -18,11 +18,11 @@ def start(self):
while True:
recent_value = paste()
if recent_value != temp_value:
result = self.translate.send_request(recent_value)
if result['status'] == True:
self.notify.send(recent_value, result['response'])
else:
print('Error: ' + str(result['response']))
try:
result = self.translate.translate(recent_value, dest='tr')
self.notify.send(recent_value, result.text)
except Exception as e:
self.notify.send('A Problem Occurred', str(e))

temp_value = recent_value
sleep(2)
28 changes: 0 additions & 28 deletions tfc/translate.py

This file was deleted.

0 comments on commit e5c81fe

Please sign in to comment.