Commit e2913f99 authored by amirreza hosseini's avatar amirreza hosseini

New update

parent ca95627a
import requests
import json
from DB import Db
class Gtranslate():
def translate(self, sl, tl, word, dbs=True):
......@@ -9,9 +11,17 @@ class Gtranslate():
dbm = dbc.searchMean(word)
if dbm is not False:
return {"exact":dbm[2], "pron":dbm[4], "othermean":dbm[3], "Error":None}
else:
dbc = Db("en2fa.db")
dbm = dbc.searchMean(word)
if dbm is not False:
return {"exact":dbm[2], "pron":dbm[4], "othermean":dbm[3], "Error":None}
try:
word = str(word).replace(".", "")
treq = requests.get(url="https://translate.google.com//translate_a/single?client=gtx&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=360000c&sl={0}sl&tl={1}tl&hl={2}&q={3}".format(sl, tl, tl, word), headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36"}, proxies={})
if sl == "":
treq = requests.get(url="https://translate.google.com//translate_a/single?client=gtx&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=360000c&tl={0}tl&hl={1}&q={2}".format(tl, tl, word), headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36"}, proxies={})
else:
treq = requests.get(url="https://translate.google.com//translate_a/single?client=gtx&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=360000c&sl={0}sl&tl={1}tl&hl={2}&q={3}".format(sl, tl, tl, word), headers={"user-agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.9 Safari/537.36"}, proxies={})
except:
return {"exact": "Connection Error", "pron":None, "othermean":None, "Error": "Connection Error!!\nCheck Your Internet Connection!"}
......@@ -31,6 +41,9 @@ class Gtranslate():
else:
pron = None
othmean = jsn[1][0][1]
if err is None:
if err is None or err == "t1":
if sl == "":
sl = str(jsn[8][0][0])
dbc = Db(sl + "2" + tl + ".db")
dbc.insertWord(word, exactmean, othmean, pron)
return {"exact":exactmean, "pron":pron, "othermean":othmean, "Error":err}
......@@ -5,18 +5,19 @@
# Installation
- You must have `python3` and `pyqt5` installed in your system.
- Then ``` git clone https://gitlab.com/SiminDictionary/Simin.git ; cd Simin ; sudo bash install.sh ```
- You must have `python3`,`pyqt5`,`notify-send` installed in your system.
- Then ``` git clone https://github.com/SiminDictionary/simin.git ; cd simin ; sudo bash install.sh ```
# Uninstall
- To Uninstall : ``` sudo bash /opt/simin/uninstall.sh ```
# Tips
- Use `Ctrl+Return` Button to translate the entered word/sentence
- Use `Ctrl+Q` Button to quit.
- Github page : [https://github.com/SiminDictionary/simin](https://github.com/SiminDictionary/simin)
- Add `simin-no` command to your keyboard shortcuts then you can use simin anywhere, anytime. Just select/highlight the word and push your shortcut. A notification shows you the translated word.
- Use `Ctrl+Return` button to translate the entered word/sentence
- Use `Ctrl+Q` button to quit.
# Credit
- SeedPuller - Email : SeedPuller@gmail.com
- Amirreza Hosseini - [Gitlab](https://gitlab.com/amirrezaw)
\ No newline at end of file
- Amirreza Hosseini - [Gitlab](https://gitlab.com/amirrezaw)
......@@ -5,6 +5,8 @@ sudo mkdir $SIMINP;
sudo cp -r * $SIMINP/
sudo cp simin /usr/bin/
sudo chmod +x $USRSIMIN
sudo cp simin-no /usr/bin/
sudo chmod +x /usr/bin/simin-no
sudo cp simin.desktop /usr/share/applications
sudo rm -rf $SIMINP/simin.desktop $SIMINP/install.sh __pycache__ $SIMINP/simin
sudo chown -R $(id -u):$(id -g) $SIMINP
\ No newline at end of file
sudo rm -rf $SIMINP/simin.desktop $SIMINP/install.sh __pycache__ $SIMINP/simin $SIMINP/simin-no
sudo chown -R $(id -u):$(id -g) $SIMINP
......@@ -125,9 +125,12 @@ class myprog(QMainWindow, Ui_MainWindow):
self.textEdit_2.setText("{0}\n\n{1}".format(gtrans["exact"], othermeans))
if __name__ == '__main__':
if len(sys.argv) > 1:
word = sys.argv[1]
gtrans = Gtranslate().translate("", "fa", word, False)
print(gtrans['exact'])
sys.exit()
app = QApplication(sys.argv)
window = myprog()
window.show()
if len(sys.argv) > 1:
window.trnsl(sys.argv[1])
sys.exit(app.exec_())
#!/bin/bash
XCLIP=$(xclip -o -select primary)
SIMINRES=$(cd /opt/simin/ ; python3 main.py $XCLIP)
notify-send -t 5000 -a Simin -i /opt/simin/icons/simin.png $XCLIP "${SIMINRES}"
File mode changed from 100644 to 100755
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment