1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-15 02:54:09 -04:00

Refactor and comment locale_dir selection

This commit is contained in:
Juhani Numminen 2019-08-12 12:37:24 +03:00
parent 93c9535216
commit a5d584371e

View file

@ -51,18 +51,21 @@ def init():
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
# install gettext # install gettext
# locale_dir = 'locale' locale_locations = (
locale_dir = None # locale/ next to the pysol.py script
if os.path.isdir(sys.path[0]): sys.path[0],
d = os.path.join(sys.path[0], 'locale') # locale/ next to library.zip (py2exe)
else: os.path.dirname(sys.path[0]),
# i.e. library.zip # locale/ in curdir (works for e.g. py2app)
d = os.path.join(os.path.dirname(sys.path[0]), 'locale') os.curdir)
if os.path.exists(d) and os.path.isdir(d): # leaving the domain unbound means sys.prefix+'/share/locale'
locale_dir = d
# if locale_dir: locale_dir = os.path.normpath(locale_dir) for par in locale_locations:
# gettext.install('pysol', locale_dir, unicode=True) # ngettext don't work locale_dir = os.path.join(par, 'locale')
gettext.bindtextdomain('pysol', locale_dir) if os.path.isdir(locale_dir):
gettext.bindtextdomain('pysol', locale_dir)
break
gettext.textdomain('pysol') gettext.textdomain('pysol')
# debug # debug