mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
cache lookup lang
This commit is contained in:
parent
789b79dbd5
commit
a3eaabbd93
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from functools import lru_cache
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAbstractItemView, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
|
QAbstractItemView, QApplication, QCheckBox, QComboBox, QDialog, QDialogButtonBox,
|
||||||
QFormLayout, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QListWidgetItem,
|
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):
|
def google_dictionary(word):
|
||||||
ans = f'https://www.google.com/search?q=define:{word}'
|
ans = f'https://www.google.com/search?q=define:{word}'
|
||||||
l = canonicalize_lang(get_lang())
|
lang = lookup_lang()
|
||||||
if l:
|
if lang:
|
||||||
l = lang_as_iso639_1(l) or l
|
ans += f'#dobc={lang}'
|
||||||
ans += f'#dobc={l}'
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user