cache lookup lang

This commit is contained in:
Kovid Goyal 2022-08-29 07:25:35 +05:30
parent 789b79dbd5
commit a3eaabbd93
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -4,6 +4,7 @@
import sys
import textwrap
from functools import lru_cache
from qt.core import (
QAbstractItemView, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
QFormLayout, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QListWidgetItem,
@ -23,12 +24,19 @@ from calibre.utils.webengine import (
)
@lru_cache
def lookup_lang():
ans = canonicalize_lang(get_lang())
if ans:
ans = lang_as_iso639_1(ans) or ans
return ans
def google_dictionary(word):
ans = f'https://www.google.com/search?q=define:{word}'
l = canonicalize_lang(get_lang())
if l:
l = lang_as_iso639_1(l) or l
ans += f'#dobc={l}'
lang = lookup_lang()
if lang:
ans += f'#dobc={lang}'
return ans