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
|
# gettext
|
||||||
_gtrans = gettext.translation(
|
_gtrans = gettext.translation(
|
||||||
'anki', dir, languages=[lang], fallback=True)
|
'anki', dir, languages=[lang], fallback=True)
|
||||||
def fn(arg, *args):
|
def fn__(arg):
|
||||||
print("accessing _ and ngettext without importing from anki.lang will break in the future")
|
print("accessing _ without importing from anki.lang will break in the future")
|
||||||
print("".join(traceback.format_stack()[-2]))
|
print("".join(traceback.format_stack()[-2]))
|
||||||
return arg
|
from anki.lang import _
|
||||||
builtins.__dict__['_'] = fn
|
return _(arg)
|
||||||
builtins.__dict__['ngettext'] = fn
|
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)
|
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)
|
||||||
|
|
Loading…
Reference in a new issue