From 515f49afbcdafc1f81c681a9f06bbed101dba55d Mon Sep 17 00:00:00 2001
From: Atikur Rahman Chitholian
This application helps translating words between Bengali and English languages.
@@ -194,19 +226,21 @@ def show_about(self):
- ==> By default this application is configured to stay above other windows; it helps improved experience of
- clipboard monitoring feature. Uncheck the "Keep window above" checkbox to turn it off.
+ ==> By default this application is configured to stay above other windows; it helps improved experience
+ of clipboard monitoring feature. Uncheck the "Keep window above" checkbox to turn it off.
- ==> Just keep this app running and copy some words (Ctrl+C) from anywhere of your device (e.g. from web browser, PDF viewer etc.)
+ ==> Just keep this app running and copy some words (Ctrl+C) from anywhere of your device (e.g. from web
+ browser, PDF viewer etc.)
- ==> This app will monitor your clipboard and show translation as soon as you copy texts. It does not require you to paste
- the selected word inside this app (although you can do so).
+ ==> This app will monitor your clipboard and show translation as soon as you copy texts. It does not
+ require you to paste the selected word inside this app (although you can do so).
- ==> Linux (X11 Window System) provides access to clipboard selection. In that case you don't even need to copy the text,
- just double click the word (or use mouse/touchpad) to select it. This app will capture and show the translation.
+ ==> Linux (X11 Window System) provides access to clipboard selection. In that case you don't even need
+ to copy the text, just double click the word (or use mouse/touchpad) to select it. This app will
+ capture and show the translation.
Nothing Found!
')
+ found = query.first()
+ if not found and is_eng:
+ self.show_not_found()
return
else:
- htm = ''
- htm += f"{html.escape(query.value(1))}
{html.escape(query.value(3))}
"
-
- ant = query.value(4)
- if ant:
- words = ', '.join([w.capitalize()
- for w in list(json.loads(ant))])
- htm += f'Antonyms
{html.escape(words)}
'
-
- data = query.value(5)
- if data:
- parts = list(json.loads(data))
- lines = ''
- for p in parts:
- lines += f"Definitions
{lines}
'
-
- types = query.value(2)
- if types:
- lists = list(json.loads(types))
- for i in lists:
- type_id = i[0]
- type_name = self.types[type_id]
- q = QSqlQuery(f"SELECT * FROM bn_en WHERE serial IN ({','.join([str(j) for j in i[1:]])})",
- self.db)
- q.exec_()
+ # Try query from bn_en table.
+ more_en = ''
+ if not is_eng:
+ extra = QSqlQuery("SELECT english FROM bn_en WHERE bangla LIKE ?", self.db)
+ extra.bindValue(0, text)
+ extra.exec_()
+ if extra.first():
+ words = extra.value(0)
+ if words:
+ words = list(json.loads(words))
+ more_en = ', '.join([w.capitalize() for w in words])
+ if not found and not more_en:
+ self.show_not_found()
+ return
+ elif not found:
+ htm = f'{html.escape(more_en)}
'
+ else:
+ more = f'
{html.escape(more_en)}' if more_en else ''
+ htm = ''
+ htm += f"{html.escape(query.value(1))}
{html.escape(query.value(3))}{more}
"
+
+ ant = query.value(4)
+ if ant:
+ words = ', '.join([w.capitalize() for w in list(json.loads(ant))])
+ htm += f'Antonyms
{html.escape(words)}
'
+
+ data = query.value(5)
+ if data:
+ parts = list(json.loads(data))
lines = ''
- while q.next():
- bn = q.value(1)
- parts = list(json.loads(q.value(2)))
- words = ', '.join([w.capitalize() for w in parts])
- lines += f'
{html.escape(bn)}
{html.escape(words)}
'
- htm += f'{html.escape(type_name)}
{lines}
'
- example = query.value(6)
- if example:
- htm += f'Example
{html.escape(example.capitalize())}'
- htm += ''
+ for p in parts:
+ lines += f"Definitions
{lines}
'
+
+ types = query.value(2)
+ if types:
+ lists = list(json.loads(types))
+ for i in lists:
+ type_id = i[0]
+ type_name = self.types[type_id]
+ q = QSqlQuery(f"SELECT * FROM bn_en WHERE serial IN ({','.join([str(j) for j in i[1:]])})",
+ self.db)
+ q.exec_()
+ lines = ''
+ while q.next():
+ bn = q.value(1)
+ parts = list(json.loads(q.value(2)))
+ words = ', '.join([w.capitalize() for w in parts])
+ lines += f'
{html.escape(bn)}
{html.escape(words)}
'
+ htm += f'{html.escape(type_name)}
{lines}
'
+ example = query.value(6)
+ if example:
+ htm += f'Example
{html.escape(example.capitalize())}'
+ htm += ''
self.outputBox.setHtml(htm)
+ def show_not_found(self):
+ self.outputBox.setHtml('Nothing Found!
')
+
def speak_now(self, text):
# TODO: Implement this
pass
@@ -180,7 +210,9 @@ def show_about(self):
Bangla Dictionary
v1.0.0
- https://github.com/chitholian/Bangla-Dictionary
+
+ https://github.com/chitholian/Bangla-Dictionary
+