diff --git a/anki/lang.py b/anki/lang.py index 693445255..416f1042a 100644 --- a/anki/lang.py +++ b/anki/lang.py @@ -63,15 +63,16 @@ def _(str): def ngettext(single, plural, n): return localTranslation().ungettext(single, plural, n) +def langDir(): + dir = os.path.join(os.path.dirname( + os.path.abspath(__file__)), "locale") + if not os.path.exists(dir): + dir = os.path.join(os.path.dirname(sys.argv[0]), "locale") + return dir + def setLang(lang, local=True): - base = os.path.dirname(os.path.abspath(__file__)) - localeDir = os.path.join(base, "locale") - if not os.path.exists(localeDir): - localeDir = os.path.join( - os.path.dirname(sys.argv[0]), "locale") - trans = gettext.translation('libanki', localeDir, - languages=[lang], - fallback=True) + trans = gettext.translation( + 'libanki', langDir(), languages=[lang], fallback=True) if local: threadLocal.currentLang = lang threadLocal.currentTranslation = trans