Browse Source

pythonlib: i18n

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44023 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 years ago
parent
commit
a7deacbfe8
5 changed files with 28 additions and 13 deletions
  1. 9 6
      lib/python/array.py
  2. 1 1
      lib/python/core.py
  3. 4 0
      lib/python/db.py
  4. 7 3
      lib/python/raster.py
  5. 7 3
      lib/python/vector.py

+ 9 - 6
lib/python/array.py

@@ -17,7 +17,6 @@ License (>=v2). Read the file COPYING that comes with GRASS
 for details.
 
 @author Glynn Clements
-
 """
 
 import os
@@ -25,6 +24,10 @@ import numpy
 
 import core as grass
 
+# i18N
+import gettext
+gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+
 class array(numpy.memmap):
     def __new__(cls, dtype = numpy.double):
 	reg = grass.region()
@@ -58,10 +61,10 @@ class array(numpy.memmap):
 	elif kind in 'biu':
 	    flags = 'i'
 	else:
-	    raise ValueError('invalid kind <%s>' % kind)
+	    raise ValueError(_('invalid kind <%s>') % kind)
 
 	if size not in [1,2,4,8]:
-	    raise ValueError('invalid size <%d>' % size)
+	    raise ValueError(_('invalid size <%d>') % size)
 
 	return grass.run_command(
 	    'r.out.bin',
@@ -83,14 +86,14 @@ class array(numpy.memmap):
 	    elif size == 8:
 		flags = 'd'
 	    else:
-		raise ValueError('invalid FP size <%d>' % size)
+		raise ValueError(_('invalid FP size <%d>') % size)
 	    size = None
 	elif kind in 'biu':
 	    if size not in [1,2,4]:
-		raise ValueError('invalid integer size <%d>' % size)
+		raise ValueError(_('invalid integer size <%d>') % size)
 	    flags = None
 	else:
-	    raise ValueError('invalid kind <%s>' % kind)
+	    raise ValueError(_('invalid kind <%s>') % kind)
 
 	reg = grass.region()
 

+ 1 - 1
lib/python/core.py

@@ -32,7 +32,7 @@ import subprocess
 
 # i18N
 import gettext
-gettext.install('grassmods', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
 
 # subprocess wrapper that uses shell on Windows
 

+ 4 - 0
lib/python/db.py

@@ -26,6 +26,10 @@ import tempfile as pytempfile # conflict with core.tempfile
 
 from core import *
 
+# i18N
+import gettext
+gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+
 def db_describe(table, **args):
     """!Return the list of columns for a database table
     (interface to `db.describe -c'). Example:

+ 7 - 3
lib/python/raster.py

@@ -27,6 +27,10 @@ import string
 
 from core import *
 
+# i18N
+import gettext
+gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+
 # add raster history
 
 def raster_history(map):
@@ -43,7 +47,8 @@ def raster_history(map):
         run_command('r.support', map = map, history = os.environ['CMDLINE'])
         return True
     
-    warning("Unable to write history for <%s>. Raster map <%s> not found in current mapset." % (map, map))
+    warning(_("Unable to write history for <%s>. "
+              "Raster map <%s> not found in current mapset." % (map, map)))
     return False
 
 # run "r.info -rgstmpud ..." and parse output
@@ -88,5 +93,4 @@ def mapcalc(exp, quiet = False, verbose = False, overwrite = False, **kwargs):
                    quiet = quiet,
                    verbose = verbose,
                    overwrite = overwrite) != 0:
-	fatal("An error occurred while running r.mapcalc")
-    
+	fatal(_("An error occurred while running r.mapcalc"))

+ 7 - 3
lib/python/vector.py

@@ -26,6 +26,10 @@ import os
 
 from core import *
 
+# i18N
+import gettext
+gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
+
 # run "v.db.connect -g ..." and parse output
 
 def vector_db(map, **args):
@@ -82,7 +86,7 @@ def vector_layer_db(map, layer):
     try:
         f = vector_db(map)[int(layer)]
     except KeyError:
-	fatal("Database connection not defined for layer %s" % layer)
+	fatal(_("Database connection not defined for layer %s") % layer)
 
     return f
 
@@ -179,7 +183,7 @@ def vector_db_select(map, layer = 1, **kwargs):
     try:
         key = vector_db(map = map)[layer]['key']
     except KeyError:
-        error('Missing layer %d in vector map <%s>' % (layer, map))
+        error(_('Missing layer %d in vector map <%s>') % (layer, map))
         return { 'columns' : [], 'values' : {} }
         
     if kwargs.has_key('columns'):
@@ -194,7 +198,7 @@ def vector_db_select(map, layer = 1, **kwargs):
                        fs = '|', **kwargs)
     
     if not ret:
-        error('vector_select() failed')
+        error(_('vector_select() failed'))
         return { 'columns' : [], 'values' : {} }
     
     columns = []