Linux: fix translation issue
This commit is contained in:
parent
77014f09c6
commit
06102e7d97
1 changed files with 17 additions and 2 deletions
|
@ -62,8 +62,23 @@ if os.name == 'nt':
|
||||||
if lang:
|
if lang:
|
||||||
os.environ['LANG'] = lang
|
os.environ['LANG'] = lang
|
||||||
|
|
||||||
#gettext.install(APP, defs.localedir)
|
localedir = "../po"
|
||||||
gettext.install(APP)
|
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:
|
if gettext._translations:
|
||||||
_translation = list(gettext._translations.values())[0]
|
_translation = list(gettext._translations.values())[0]
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue