소스 검색

wxGUI/translations: fixing broken compilation and startup (caused by https://trac.osgeo.org/grass/changeset/57219)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@57220 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 11 년 전
부모
커밋
1423e794bb
4개의 변경된 파일28개의 추가작업 그리고 11개의 파일을 삭제
  1. 9 2
      gui/wxpython/core/gcmd.py
  2. 9 2
      gui/wxpython/core/globalvar.py
  3. 9 4
      gui/wxpython/core/utils.py
  4. 1 3
      gui/wxpython/gis_set.py

+ 9 - 2
gui/wxpython/core/gcmd.py

@@ -50,8 +50,15 @@ from core       import globalvar
 from core.debug import Debug
 from core.debug import Debug
 
 
 # cannot import from the core.utils module to avoid cross dependencies
 # cannot import from the core.utils module to avoid cross dependencies
-import gettext
-_ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
+try:
+    # intended to be used also outside this module
+    import gettext
+    _ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
+except IOError:
+    # using no translation silently
+    def null_gettext(string):
+        return string
+    _ = null_gettext
 
 
 def GetRealCmd(cmd):
 def GetRealCmd(cmd):
     """!Return real command name - only for MS Windows
     """!Return real command name - only for MS Windows

+ 9 - 2
gui/wxpython/core/globalvar.py

@@ -28,8 +28,15 @@ ETCSYMBOLDIR = os.path.join(ETCDIR, "gui", "images", "symbols")
 from core.debug import Debug
 from core.debug import Debug
 
 
 # cannot import from the core.utils module to avoid cross dependencies
 # cannot import from the core.utils module to avoid cross dependencies
-import gettext
-_ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
+try:
+    # intended to be used also outside this module
+    import gettext
+    _ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
+except IOError:
+    # using no translation silently
+    def null_gettext(string):
+        return string
+    _ = null_gettext
 
 
 if os.path.join(ETCDIR, "python") not in sys.path:
 if os.path.join(ETCDIR, "python") not in sys.path:
     sys.path.append(os.path.join(ETCDIR, "python"))
     sys.path.append(os.path.join(ETCDIR, "python"))

+ 9 - 4
gui/wxpython/core/utils.py

@@ -32,10 +32,15 @@ from core.gcmd  import RunCommand
 from core.debug import Debug
 from core.debug import Debug
 # from core.settings import UserSettings
 # from core.settings import UserSettings
 
 
-# intended to be used also outside this module
-import gettext
-_ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
-
+try:
+    # intended to be used also outside this module
+    import gettext
+    _ = gettext.translation('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale')).ugettext
+except IOError:
+    # using no translation silently
+    def null_gettext(string):
+        return string
+    _ = null_gettext
 
 
 def normalize_whitespace(text):
 def normalize_whitespace(text):
     """!Remove redundant whitespace from a string"""
     """!Remove redundant whitespace from a string"""

+ 1 - 3
gui/wxpython/gis_set.py

@@ -28,15 +28,13 @@ import platform
 import codecs
 import codecs
 import getpass
 import getpass
 
 
-### i18N
-gettext.install('grasswxpy', os.path.join(os.getenv("GISBASE"), 'locale'), unicode = True)
-
 if __name__ == "__main__":
 if __name__ == "__main__":
     gui_wx_path = os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython')
     gui_wx_path = os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'wxpython')
     if gui_wx_path not in sys.path:
     if gui_wx_path not in sys.path:
         sys.path.append(gui_wx_path)
         sys.path.append(gui_wx_path)
 
 
 from core import globalvar
 from core import globalvar
+from core.utils import _
 import wx
 import wx
 import wx.lib.mixins.listctrl as listmix
 import wx.lib.mixins.listctrl as listmix
 import wx.lib.scrolledpanel as scrolled
 import wx.lib.scrolledpanel as scrolled