-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtranslator.py
More file actions
36 lines (32 loc) · 840 Bytes
/
translator.py
File metadata and controls
36 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys
from plyer import *
from googletrans import Translator
import time
import os
import pyperclip
# method of translation process
def translation(text):
# initiate instance
trans_item = Translator()
var = trans_item.translate(text, dest='ar')
notification.notify(
title=var.origin,
message=var.text,
app_name='Translator',
ticker='',
app_icon='logo.ico',
timeout=10
)
sys.path.append(os.path.abspath("SO_site-packages"))
current_text = ""
while True:
# temporary value of clipboard chash memory
tmp_text = pyperclip.paste()
try:
if tmp_text != current_text:
current_text = tmp_text
translation(current_text)
except:
# pass or you could use 'continue' for iterated looping
pass
time.sleep(0.1)