mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
factor langDir into separate func
This commit is contained in:
parent
a0578f73d1
commit
cbdd152f36
1 changed files with 9 additions and 8 deletions
17
anki/lang.py
17
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
|
||||
|
|
Loading…
Reference in a new issue