Commit 8a5a35059d9482f13d32152437fc9e44bd12c586
1 parent
a9f1e82f
Exists in
master
Handling locale setting error
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
app.py
@@ -178,7 +178,10 @@ class SplashScreen(wx.SplashScreen): | @@ -178,7 +178,10 @@ class SplashScreen(wx.SplashScreen): | ||
178 | if lang: | 178 | if lang: |
179 | # print "LANG", lang, _, wx.Locale(), wx.GetLocale() | 179 | # print "LANG", lang, _, wx.Locale(), wx.GetLocale() |
180 | import locale | 180 | import locale |
181 | - locale.setlocale(locale.LC_ALL, '') | 181 | + try: |
182 | + locale.setlocale(locale.LC_ALL, '') | ||
183 | + except locale.Error: | ||
184 | + pass | ||
182 | # For pt_BR, splash_pt.png should be used | 185 | # For pt_BR, splash_pt.png should be used |
183 | if (lang.startswith('pt')): | 186 | if (lang.startswith('pt')): |
184 | icon_file = "splash_pt.png" | 187 | icon_file = "splash_pt.png" |
invesalius/gui/language_dialog.py
@@ -56,7 +56,10 @@ class ComboBoxLanguage: | @@ -56,7 +56,10 @@ class ComboBoxLanguage: | ||
56 | # Find out OS locale | 56 | # Find out OS locale |
57 | self.os_locale = i18n.GetLocaleOS() | 57 | self.os_locale = i18n.GetLocaleOS() |
58 | 58 | ||
59 | - os_lang = self.os_locale[0:2] | 59 | + try: |
60 | + os_lang = self.os_locale[0:2] | ||
61 | + except TypeError: | ||
62 | + os_lang = None | ||
60 | 63 | ||
61 | # Default selection will be English | 64 | # Default selection will be English |
62 | selection = self.locales_key.index('en') | 65 | selection = self.locales_key.index('en') |
@@ -70,7 +73,7 @@ class ComboBoxLanguage: | @@ -70,7 +73,7 @@ class ComboBoxLanguage: | ||
70 | # Add bitmap and info to Combo | 73 | # Add bitmap and info to Combo |
71 | bitmapCmb.Append(dict_locales[key], bmp, key) | 74 | bitmapCmb.Append(dict_locales[key], bmp, key) |
72 | # Set default combo item if available on the list | 75 | # Set default combo item if available on the list |
73 | - if key.startswith(os_lang): | 76 | + if os_lang and key.startswith(os_lang): |
74 | selection = self.locales_key.index(key) | 77 | selection = self.locales_key.index(key) |
75 | bitmapCmb.SetSelection(selection) | 78 | bitmapCmb.SetSelection(selection) |
76 | 79 |