[GRASS-SVN] r51371 - grass/trunk/gui/wxpython/core
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 11 05:06:28 EDT 2012
Author: martinl
Date: 2012-04-11 02:06:28 -0700 (Wed, 11 Apr 2012)
New Revision: 51371
Modified:
grass/trunk/gui/wxpython/core/gcmd.py
grass/trunk/gui/wxpython/core/settings.py
Log:
wxGUI: don't fail when locale is invalid
Modified: grass/trunk/gui/wxpython/core/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/core/gcmd.py 2012-04-10 22:26:27 UTC (rev 51370)
+++ grass/trunk/gui/wxpython/core/gcmd.py 2012-04-11 09:06:28 UTC (rev 51371)
@@ -67,8 +67,13 @@
"""
if not string:
return string
+
+ try:
+ enc = locale.getdefaultlocale()[1]
+ except ValueError, e:
+ sys.stderr.write(_("ERROR: %s\n") % str(e))
+ return string
- enc = locale.getdefaultlocale()[1]
if enc:
Debug.msg(5, "DecodeString(): enc=%s" % enc)
return string.decode(enc)
Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py 2012-04-10 22:26:27 UTC (rev 51370)
+++ grass/trunk/gui/wxpython/core/settings.py 2012-04-11 09:06:28 UTC (rev 51371)
@@ -54,13 +54,20 @@
def _generateLocale(self):
"""!Generate locales
"""
- loc = list(locale.getdefaultlocale())
- if loc[1] == 'UTF8':
- loc[1] = 'UTF-8'
- code_loc = "%s.%s" % (loc[0],loc[1])
+ # collect available locales
self.locs = list(set(locale.locale_alias.values()))
self.locs.append('en_GB.UTF-8')
self.locs.sort()
+
+ try:
+ loc = list(locale.getdefaultlocale())
+ except ValueError, e:
+ sys.stderr.write(_('ERROR: %s\n') % str(e))
+ return 'C'
+
+ if loc[1] == 'UTF8':
+ loc[1] = 'UTF-8'
+ code_loc = "%s.%s" % (loc[0], loc[1])
if code_loc in self.locs:
return code_loc
More information about the grass-commit
mailing list