From cbdd152f36db1f3f67fcc591b29611633c02180c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 18 Apr 2012 03:19:47 +0900 Subject: [PATCH] factor langDir into separate func --- anki/lang.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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