mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
print warning when add-ons access _ without importing it
This commit is contained in:
parent
da2ddcc6e2
commit
919738a9d7
2 changed files with 5 additions and 6 deletions
|
@ -137,8 +137,11 @@ def setupLang(pm, app, force=None):
|
||||||
# gettext
|
# gettext
|
||||||
_gtrans = gettext.translation(
|
_gtrans = gettext.translation(
|
||||||
'anki', dir, languages=[lang], fallback=True)
|
'anki', dir, languages=[lang], fallback=True)
|
||||||
builtins.__dict__['_'] = _gtrans.gettext
|
def fn(*args):
|
||||||
builtins.__dict__['ngettext'] = _gtrans.ngettext
|
print("accessing _ and ngettext without importing from anki.lang will break in the future")
|
||||||
|
print("".join(traceback.format_stack()[-2]))
|
||||||
|
builtins.__dict__['_'] = fn
|
||||||
|
builtins.__dict__['ngettext'] = fn
|
||||||
anki.lang.setLang(lang, local=False)
|
anki.lang.setLang(lang, local=False)
|
||||||
if lang in ("he","ar","fa"):
|
if lang in ("he","ar","fa"):
|
||||||
app.setLayoutDirection(Qt.RightToLeft)
|
app.setLayoutDirection(Qt.RightToLeft)
|
||||||
|
|
|
@ -357,10 +357,6 @@ please see:
|
||||||
# On first run, allow the user to choose the default language
|
# On first run, allow the user to choose the default language
|
||||||
|
|
||||||
def _setDefaultLang(self):
|
def _setDefaultLang(self):
|
||||||
# the dialog expects _ to be defined, but we're running before
|
|
||||||
# setupLang() has been called. so we create a dummy op for now
|
|
||||||
import builtins
|
|
||||||
builtins.__dict__['_'] = lambda x: x
|
|
||||||
# create dialog
|
# create dialog
|
||||||
class NoCloseDiag(QDialog):
|
class NoCloseDiag(QDialog):
|
||||||
def reject(self):
|
def reject(self):
|
||||||
|
|
Loading…
Reference in a new issue