[GRASS-SVN] r52548 - in grass/trunk: gui/wxpython/core gui/wxpython/gui_core lib/init
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Aug 5 22:52:09 PDT 2012
Author: marisn
Date: 2012-08-05 22:52:09 -0700 (Sun, 05 Aug 2012)
New Revision: 52548
Modified:
grass/trunk/gui/wxpython/core/settings.py
grass/trunk/gui/wxpython/gui_core/preferences.py
grass/trunk/lib/init/grass.py
Log:
Add system locale option to language switching; Fail back to system locale in case of error
Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py 2012-08-05 20:49:01 UTC (rev 52547)
+++ grass/trunk/gui/wxpython/core/settings.py 2012-08-06 05:52:09 UTC (rev 52548)
@@ -58,7 +58,11 @@
self.locs = os.listdir(os.path.join(os.environ['GISBASE'], 'locale'))
self.locs.sort()
+ # Add a default choice to not override system locale
+ self.locs.insert(0, 'system')
+ return 'system'
+
def _defaultSettings(self):
"""!Define default settings
"""
Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py 2012-08-05 20:49:01 UTC (rev 52547)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py 2012-08-06 05:52:09 UTC (rev 52548)
@@ -138,6 +138,8 @@
value = win.SetSelection(value)
elif win.GetName() == 'GetStringSelection':
value = win.SetStringSelection(value)
+ elif win.GetName() == 'GetLabel':
+ value = win.SetLabel(value)
else:
value = win.SetValue(value)
@@ -163,11 +165,15 @@
Posts event EVT_SETTINGS_CHANGED.
"""
if self._updateSettings():
+ if self.settings.Get(group = 'language', key = 'locale', subkey = 'lc_all') == 'system':
+ self.settings.Set(group = 'language', key = 'locale', subkey = 'lc_all', value = None)
self.settings.SaveToFile()
self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
lang = UserSettings.Get(group = 'language', key = 'locale', subkey = 'lc_all')
if lang:
RunCommand('g.gisenv', set = 'LANG=%s' % lang)
+ else:
+ RunCommand('g.gisenv', set = 'LANG=')
event = wxSettingsChanged()
wx.PostEvent(self, event)
self.Close()
Modified: grass/trunk/lib/init/grass.py
===================================================================
--- grass/trunk/lib/init/grass.py 2012-08-05 20:49:01 UTC (rev 52547)
+++ grass/trunk/lib/init/grass.py 2012-08-06 05:52:09 UTC (rev 52548)
@@ -663,10 +663,14 @@
locale.setlocale(locale.LC_MESSAGES, language)
except:
# If we got so far, provided locale is not supported on this system
- # C is safe failback.
- print "Failed to set LC_MESSAGES to %s. Giving up." % language
- language = 'C'
+ print "Failed to set LC_MESSAGES to %s as defined by g.gisenv LANG parameter" % language
+ default_locale = locale.getdefaultlocale()
+ if default_locale[0]:
+ language = default_locale[0]
+ else:
+ language = 'C'
os.environ['LANGUAGE'] = language
+ os.environ['LANG'] = language
os.environ['LC_MESSAGES'] = language
# Calling gettext.install twice seems to allow to see also localized startup messages
# Black magic ;)
More information about the grass-commit
mailing list