print warning when add-ons access _ without importing it
This commit is contained in:
parent
da2ddcc6e2
commit
919738a9d7
@ -137,8 +137,11 @@ def setupLang(pm, app, force=None):
|
||||
# gettext
|
||||
_gtrans = gettext.translation(
|
||||
'anki', dir, languages=[lang], fallback=True)
|
||||
builtins.__dict__['_'] = _gtrans.gettext
|
||||
builtins.__dict__['ngettext'] = _gtrans.ngettext
|
||||
def fn(*args):
|
||||
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)
|
||||
if lang in ("he","ar","fa"):
|
||||
app.setLayoutDirection(Qt.RightToLeft)
|
||||
|
@ -357,10 +357,6 @@ please see:
|
||||
# On first run, allow the user to choose the default language
|
||||
|
||||
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
|
||||
class NoCloseDiag(QDialog):
|
||||
def reject(self):
|
||||
|
Loading…
Reference in New Issue
Block a user