|
@@ -23,11 +23,13 @@ This program is free software under the GNU General Public License
|
|
|
@author Michael Barton (Arizona State University)
|
|
|
@author Martin Landa <landa.martin gmail.com>
|
|
|
@author Vaclav Petras <wenzeslaus gmail.com> (menu customization)
|
|
|
+@author Luca Delucchi <lucadeluge gmail.com> (language choice)
|
|
|
"""
|
|
|
|
|
|
import os
|
|
|
import sys
|
|
|
import copy
|
|
|
+import locale
|
|
|
try:
|
|
|
import pwd
|
|
|
havePwd = True
|
|
@@ -44,7 +46,7 @@ from grass.script import core as grass
|
|
|
|
|
|
from core import globalvar
|
|
|
from core.gcmd import RunCommand
|
|
|
-from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes
|
|
|
+from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
|
|
|
from core.settings import UserSettings
|
|
|
|
|
|
wxSettingsChanged, EVT_SETTINGS_CHANGED = NewEvent()
|
|
@@ -160,6 +162,23 @@ class PreferencesBaseDialog(wx.Dialog):
|
|
|
if self._updateSettings():
|
|
|
self.settings.SaveToFile()
|
|
|
self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
|
|
|
+ fileSettings = {}
|
|
|
+ self.settings.ReadSettingsFile(settings = fileSettings)
|
|
|
+ id_loc = fileSettings['language']['locale']['lc_all']
|
|
|
+ rcfile = open(os.path.join(GetSettingsPath(), 'bashrc'),"r")
|
|
|
+ rclines = rcfile.readlines()
|
|
|
+ rcfile.close()
|
|
|
+ rcfile = open(os.path.join(GetSettingsPath(), 'bashrc'),"w")
|
|
|
+ grasslang = False
|
|
|
+ for line in rclines:
|
|
|
+ if 'GRASS_LANG' in line:
|
|
|
+ rcfile.write('GRASS_LANG: %s\n' % self.locales[id_loc])
|
|
|
+ grasslang = True
|
|
|
+ else:
|
|
|
+ rcfile.write('%s' % line)
|
|
|
+ if not grasslang:
|
|
|
+ rcfile.write('GRASS_LANG: %s\n' % self.locales[id_loc])
|
|
|
+ rcfile.close()
|
|
|
event = wxSettingsChanged()
|
|
|
wx.PostEvent(self, event)
|
|
|
self.Close()
|
|
@@ -408,6 +427,37 @@ class PreferencesDialog(PreferencesBaseDialog):
|
|
|
pos = (row, 1))
|
|
|
|
|
|
#
|
|
|
+ # languages
|
|
|
+ #
|
|
|
+ box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Set language)"))
|
|
|
+ sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
|
|
|
+
|
|
|
+ gridSizer = wx.GridBagSizer (hgap = 3, vgap = 3)
|
|
|
+ gridSizer.AddGrowableCol(0)
|
|
|
+ sizer.Add(item = gridSizer, proportion = 1, flag = wx.ALL | wx.EXPAND, border = 5)
|
|
|
+ border.Add(item = sizer, proportion = 0, flag = wx.ALL | wx.EXPAND, border = 3)
|
|
|
+
|
|
|
+ row = 0
|
|
|
+ gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
|
|
|
+ label = _("Choose language (requires to save and GRASS restart)::")),
|
|
|
+ flag = wx.ALIGN_LEFT |
|
|
|
+ wx.ALIGN_CENTER_VERTICAL,
|
|
|
+ pos = (row, 0))
|
|
|
+ self.locales = self.settings.Get(group = 'language', key = 'locale',
|
|
|
+ subkey = 'choices', internal = True)
|
|
|
+ elementList = wx.Choice(parent = panel, id = wx.ID_ANY, size = (325, -1),
|
|
|
+ choices = self.locales, name = "GetSelection")
|
|
|
+ if self.settings.Get(group = 'language', key = 'locale',
|
|
|
+ subkey = 'lc_all'):
|
|
|
+ elementList.SetSelection(self.settings.Get(group = 'language',
|
|
|
+ key = 'locale', subkey = 'lc_all'))
|
|
|
+ self.winId['language:locale:lc_all'] = elementList.GetId()
|
|
|
+
|
|
|
+ gridSizer.Add(item = elementList,
|
|
|
+ flag = wx.ALIGN_RIGHT |
|
|
|
+ wx.ALIGN_CENTER_VERTICAL,
|
|
|
+ pos = (row, 1))
|
|
|
+ #
|
|
|
# appearence
|
|
|
#
|
|
|
box = wx.StaticBox (parent = panel, id = wx.ID_ANY, label = " %s " % _("Appearance settings"))
|
|
@@ -443,7 +493,7 @@ class PreferencesDialog(PreferencesBaseDialog):
|
|
|
#
|
|
|
row += 1
|
|
|
gridSizer.Add(item = wx.StaticText(parent = panel, id = wx.ID_ANY,
|
|
|
- label = _("Menu style (requires GUI restart):")),
|
|
|
+ label = _("Menu style (requires to save and GUI restart):")),
|
|
|
flag = wx.ALIGN_LEFT |
|
|
|
wx.ALIGN_CENTER_VERTICAL,
|
|
|
pos = (row, 0))
|
|
@@ -1156,7 +1206,6 @@ class PreferencesDialog(PreferencesBaseDialog):
|
|
|
winCode.SetValue('')
|
|
|
win.SetValue('')
|
|
|
|
|
|
-
|
|
|
try:
|
|
|
win.SetValue(self.epsgCodeDict[code][1].replace('<>', '').strip())
|
|
|
except KeyError:
|