Skip to content

Commit

Permalink
Smarter handling of locale, but still not working on OSX app bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlotte Curtis authored and Charlotte Curtis committed Dec 17, 2020
1 parent 3614f77 commit 4430918
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions pdfstitcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,28 @@ def resource_path(relative_path):

return os.path.join(base_path, relative_path)

language_warning = None

lc = locale.getdefaultlocale()

# supported languages are currently german, spanish, french, dutch. Fallback in English.
lang = lc[0][:2]
language_warning = None
try:
lang = lc[0][:2]
except:
lang = 'en'
language_warning = 'Could not detect system language, defaulting to English'

if lang in ('de','es','fr','nl'):
os.environ['LC_MESSAGES'] = lang
elif lang != 'en':
if lang not in ('de','es','fr','nl','en'):
language_warning = 'System language code ' + lang + ' is not supported, defaulting to English.'

translate = gettext.translation('pdfstitcher', resource_path('locale'), fallback=True)
translate.install()
else:
try:
translate = gettext.translation('pdfstitcher', resource_path('locale'),
languages=[lang], fallback=True)
translate.install()
except Exception as e:
def _(text):
return text

language_warning = e

class SewGUI(wx.Frame):
def __init__(self, *args, **kw):
Expand Down

0 comments on commit 4430918

Please sign in to comment.