mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
keep global i18n handlers working
the previous change broke the translations of copy&pasted anki code in add-ons should fix https://anki.tenderapp.com/discussions/ankidesktop/32922-chinese-characters-in-the-main-window-when-setting-language-to-japanese#comment_47043676
This commit is contained in:
parent
0543df7dfa
commit
79660e41bb
1 changed files with 12 additions and 5 deletions
|
@ -137,12 +137,19 @@ def setupLang(pm, app, force=None):
|
|||
# gettext
|
||||
_gtrans = gettext.translation(
|
||||
'anki', dir, languages=[lang], fallback=True)
|
||||
def fn(arg, *args):
|
||||
print("accessing _ and ngettext without importing from anki.lang will break in the future")
|
||||
def fn__(arg):
|
||||
print("accessing _ without importing from anki.lang will break in the future")
|
||||
print("".join(traceback.format_stack()[-2]))
|
||||
return arg
|
||||
builtins.__dict__['_'] = fn
|
||||
builtins.__dict__['ngettext'] = fn
|
||||
from anki.lang import _
|
||||
return _(arg)
|
||||
def fn_ngettext(a, b, c):
|
||||
print("accessing ngettext without importing from anki.lang will break in the future")
|
||||
print("".join(traceback.format_stack()[-2]))
|
||||
from anki.lang import ngettext
|
||||
return ngettext(a, b, c)
|
||||
|
||||
builtins.__dict__['_'] = fn__
|
||||
builtins.__dict__['ngettext'] = fn_ngettext
|
||||
anki.lang.setLang(lang, local=False)
|
||||
if lang in ("he","ar","fa"):
|
||||
app.setLayoutDirection(Qt.RightToLeft)
|
||||
|
|
Loading…
Reference in a new issue