Linux: fix translation issue

This commit is contained in:
André Apitzsch 2017-09-08 00:41:30 +02:00
parent 77014f09c6
commit 06102e7d97
1 changed files with 17 additions and 2 deletions

View File

@ -62,8 +62,23 @@ if os.name == 'nt':
if lang:
os.environ['LANG'] = lang
#gettext.install(APP, defs.localedir)
gettext.install(APP)
localedir = "../po"
else:
# try to find domain in localedir
path = gettext.find(APP)
if path:
# extract localedir from localedir/language/LC_MESSAGES/domain.mo
path, tail = os.path.split(path)
path, tail = os.path.split(path)
localedir, tail = os.path.split(path)
else: # fallback to user locale
base = os.getenv('XDG_DATA_HOME')
if base is None or base[0] != '/':
base = os.path.expanduser('~/.local/share')
localedir = os.path.join(base, "locale")
locale.bindtextdomain(APP, localedir)
gettext.install(APP, localedir)
if gettext._translations:
_translation = list(gettext._translations.values())[0]
else: