108 changes: 54 additions & 54 deletions python/plugins/db_manager/db_plugins/info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -36,14 +36,14 @@ def __del__(self):
def generalInfo(self):
info = self.db.connector.getInfo()
tbl = [
("Server version: ", info[0])
(QApplication.translate("DBManagerPlugin", "Server version: "), info[0])
]
return HtmlTable( tbl )

def connectionDetails(self):
tbl = [
("Host:", self.db.connector.host),
("User:", self.db.connector.user)
(QApplication.translate("DBManagerPlugin", "Host:"), self.db.connector.host),
(QApplication.translate("DBManagerPlugin", "User:"), self.db.connector.user)
]
return HtmlTable( tbl )

Expand All @@ -55,28 +55,28 @@ def spatialInfo(self):
return

tbl = [
("Library:", info[0]),
(QApplication.translate("DBManagerPlugin", "Library:"), info[0]),
("GEOS:", info[1]),
("Proj:", info[2])
]
ret.append( HtmlTable( tbl ) )

if not self.db.connector.has_geometry_columns:
ret.append( HtmlParagraph( u"<warning> geometry_columns table doesn't exist!\n" \
"This table is essential for many GIS applications for enumeration of tables." ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> geometry_columns table doesn't exist!\n"
"This table is essential for many GIS applications for enumeration of tables." ) ) )

return ret

def privilegesDetails(self):
details = self.db.connector.getDatabasePrivileges()
lst = []
if details[0]: lst.append("create new schemas")
if details[1]: lst.append("create temporary tables")
if details[0]: lst.append(QApplication.translate("DBManagerPlugin", "create new schemas"))
if details[1]: lst.append(QApplication.translate("DBManagerPlugin", "create temporary tables"))
return HtmlList( lst )

def toHtml(self):
if self.db == None:
return HtmlSection( 'Not connected' ).toHtml()
return HtmlSection( QApplication.translate("DBManagerPlugin", 'Not connected') ).toHtml()

ret = []

Expand All @@ -85,14 +85,14 @@ def toHtml(self):
if conn_details == None:
pass
else:
ret.append( HtmlSection( 'Connection details', conn_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Connection details'), conn_details ) )

# database information
general_info = self.generalInfo()
if general_info == None:
pass
else:
ret.append( HtmlSection( 'General info', general_info ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'General info'), general_info ) )

# has spatial enabled?
spatial_info = self.spatialInfo()
Expand All @@ -102,7 +102,7 @@ def toHtml(self):
typename = self.db.connection().typeNameString()
spatial_info = HtmlContent( spatial_info )
if not spatial_info.hasContents():
spatial_info = '<warning> %s support not enabled!' % typename
spatial_info = QApplication.translate("DBManagerPlugin", '<warning> %s support not enabled!') % typename
ret.append( HtmlSection( typename, spatial_info ) )

# privileges
Expand All @@ -112,10 +112,10 @@ def toHtml(self):
else:
priv_details = HtmlContent( priv_details )
if not priv_details.hasContents():
priv_details = u'<warning> This user has no privileges!'
priv_details = QApplication.translate("DBManagerPlugin", '<warning> This user has no privileges!')
else:
priv_details = [ "User has privileges:", priv_details ]
ret.append( HtmlSection( 'Privileges', priv_details ) )
priv_details = [ QApplication.translate("DBManagerPlugin", "User has privileges:"), priv_details ]
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Privileges'), priv_details ) )

return HtmlContent( ret ).toHtml()

Expand All @@ -132,16 +132,16 @@ def generalInfo(self):
#("Tables:", self.schema.tableCount)
]
if self.schema.owner:
tbl.append( ("Owner:", self.schema.owner) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Owner:"), self.schema.owner) )
if self.schema.comment:
tbl.append( ("Comment:", self.schema.comment) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Comment:"), self.schema.comment) )
return HtmlTable( tbl )

def privilegesDetails(self):
details = self.schema.database().connector.getSchemaPrivileges(self.schema.name)
lst = []
if details[0]: lst.append("create new objects")
if details[1]: lst.append("access objects")
if details[0]: lst.append(QApplication.translate("DBManagerPlugin", "create new objects"))
if details[1]: lst.append(QApplication.translate("DBManagerPlugin", "access objects"))
return HtmlList( lst )

def toHtml(self):
Expand All @@ -151,18 +151,18 @@ def toHtml(self):
if general_info == None:
pass
else:
ret.append( HtmlSection( 'Schema details', general_info ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Schema details'), general_info ) )

priv_details = self.privilegesDetails()
if priv_details == None:
pass
else:
priv_details = HtmlContent( priv_details )
if not priv_details.hasContents():
priv_details = u'<warning> This user has no privileges to access this schema!'
priv_details = QApplication.translate("DBManagerPlugin", '<warning> This user has no privileges to access this schema!')
else:
priv_details = [ "User has privileges:", priv_details ]
ret.append( HtmlSection( 'Privileges', priv_details ) )
priv_details = [ QApplication.translate("DBManagerPlugin", "User has privileges:"), priv_details ]
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Privileges'), priv_details ) )

return HtmlContent( ret ).toHtml()

Expand All @@ -183,11 +183,11 @@ def generalInfo(self):
self.table.blockSignals(False)

tbl = [
("Relation type:", "View" if self.table.isView else "Table"),
("Rows:", self.table.rowCount if self.table.rowCount != None else 'Unknown (<a href="action:rows/count">find out</a>)')
(QApplication.translate("DBManagerPlugin", "Relation type:"), QApplication.translate("DBManagerPlugin", "View") if self.table.isView else QApplication.translate("DBManagerPlugin", "Table")),
(QApplication.translate("DBManagerPlugin", "Rows:"), self.table.rowCount if self.table.rowCount != None else QApplication.translate("DBManagerPlugin", 'Unknown (<a href="action:rows/count">find out</a>)'))
]
if self.table.comment:
tbl.append( ("Comment:", self.table.comment) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Comment:"), self.table.comment) )

return HtmlTable( tbl )

Expand All @@ -200,7 +200,7 @@ def fieldsDetails(self):
tbl = []

# define the table header
header = ( "#", "Name", "Type", "Null", "Default" )
header = ( "#", QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Type"), QApplication.translate("DBManagerPlugin", "Null"), QApplication.translate("DBManagerPlugin", "Default") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -223,7 +223,7 @@ def constraintsDetails(self):
tbl = []

# define the table header
header = ( "Name", "Type", "Column(s)" )
header = ( QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Type"), QApplication.translate("DBManagerPlugin", "Column(s)") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -242,7 +242,7 @@ def indexesDetails(self):
tbl = []

# define the table header
header = ( "Name", "Column(s)" )
header = ( QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Column(s)") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -261,7 +261,7 @@ def triggersDetails(self):
tbl = []

# define the table header
header = ( "Name", "Function" )
header = ( QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Function") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -286,7 +286,7 @@ def getTableInfo(self):
if general_info == None:
pass
else:
ret.append( HtmlSection( 'General info', general_info ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'General info'), general_info ) )

# spatial info
spatial_info = self.spatialInfo()
Expand All @@ -295,36 +295,36 @@ def getTableInfo(self):
else:
spatial_info = HtmlContent( spatial_info )
if not spatial_info.hasContents():
spatial_info = u'<warning> This is not a spatial table.'
spatial_info = QApplication.translate("DBManagerPlugin", '<warning> This is not a spatial table.')
ret.append( HtmlSection( self.table.database().connection().typeNameString(), spatial_info ) )

# fields
fields_details = self.fieldsDetails()
if fields_details == None:
pass
else:
ret.append( HtmlSection( 'Fields', fields_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Fields'), fields_details ) )

# constraints
constraints_details = self.constraintsDetails()
if constraints_details == None:
pass
else:
ret.append( HtmlSection( 'Constraints', constraints_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Constraints'), constraints_details ) )

# indexes
indexes_details = self.indexesDetails()
if indexes_details == None:
pass
else:
ret.append( HtmlSection( 'Indexes', indexes_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Indexes'), indexes_details ) )

# triggers
triggers_details = self.triggersDetails()
if triggers_details == None:
pass
else:
ret.append( HtmlSection( 'Triggers', triggers_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Triggers'), triggers_details ) )

return ret

Expand All @@ -340,7 +340,7 @@ def getViewInfo(self):
if view_def == None:
pass
else:
ret.append( HtmlSection( 'View definition', view_def ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'View definition'), view_def ) )

return ret

Expand All @@ -363,18 +363,18 @@ def spatialInfo(self):
return ret

tbl = [
("Column:", self.table.geomColumn),
("Geometry:", self.table.geomType)
(QApplication.translate("DBManagerPlugin", "Column:"), self.table.geomColumn),
(QApplication.translate("DBManagerPlugin", "Geometry:"), self.table.geomType)
]

# only if we have info from geometry_columns
if self.table.geomDim:
tbl.append( ("Dimension:", self.table.geomDim) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Dimension:"), self.table.geomDim) )

srid = self.table.srid if self.table.srid != None else -1
sr_info = self.table.database().connector.getSpatialRefInfo(srid) if srid != -1 else "Undefined"
sr_info = self.table.database().connector.getSpatialRefInfo(srid) if srid != -1 else QApplication.translate("DBManagerPlugin", "Undefined")
if sr_info:
tbl.append( ("Spatial ref:", u"%s (%d)" % (sr_info, srid)) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Spatial ref:"), u"%s (%d)" % (sr_info, srid)) )

# estimated extent
if not self.table.isView:
Expand All @@ -387,25 +387,25 @@ def spatialInfo(self):

if self.table.estimatedExtent != None and self.table.estimatedExtent[0] != None:
estimated_extent_str = '%.5f, %.5f - %.5f, %.5f' % self.table.estimatedExtent
tbl.append( ("Estimated extent:", estimated_extent_str) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Estimated extent:"), estimated_extent_str) )

# extent
if self.table.extent != None and self.table.extent[0] != None:
extent_str = '%.5f, %.5f - %.5f, %.5f' % self.table.extent
else:
extent_str = '(unknown) (<a href="action:extent/get">find out</a>)'
tbl.append( ("Extent:", extent_str) )
extent_str = QApplication.translate("DBManagerPlugin", '(unknown) (<a href="action:extent/get">find out</a>)')
tbl.append( (QApplication.translate("DBManagerPlugin", "Extent:"), extent_str) )

ret.append( HtmlTable( tbl ) )

# is there an entry in geometry_columns?
if self.table.geomType.lower() == 'geometry':
ret.append( HtmlParagraph( u"<warning> There isn't entry in geometry_columns!" ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> There isn't entry in geometry_columns!") ) )

# find out whether the geometry column has spatial index on it
if not self.table.isView:
if not self.table.hasSpatialIndex():
ret.append( HtmlParagraph( u'<warning> No spatial index defined (<a href="action:spatialindex/create">create it</a>)' ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", '<warning> No spatial index defined (<a href="action:spatialindex/create">create it</a>)') ) )

return ret

Expand All @@ -419,22 +419,22 @@ def spatialInfo(self):
return ret

tbl = [
("Column:", self.table.geomColumn),
("Geometry:", self.table.geomType)
(QApplication.translate("DBManagerPlugin", "Column:"), self.table.geomColumn),
(QApplication.translate("DBManagerPlugin", "Geometry:"), self.table.geomType)
]

# only if we have info from geometry_columns
srid = self.table.srid if self.table.srid != None else -1
sr_info = self.table.database().connector.getSpatialRefInfo(srid) if srid != -1 else "Undefined"
sr_info = self.table.database().connector.getSpatialRefInfo(srid) if srid != -1 else QApplication.translate("DBManagerPlugin", "Undefined")
if sr_info:
tbl.append( ("Spatial ref:", u"%s (%d)" % (sr_info, srid)) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Spatial ref:"), u"%s (%d)" % (sr_info, srid)) )

# extent
if self.table.extent != None and self.table.extent[0] != None:
extent_str = '%.5f, %.5f - %.5f, %.5f' % self.table.extent
else:
extent_str = '(unknown) (<a href="action:extent/get">find out</a>)'
tbl.append( ("Extent:", extent_str) )
extent_str = QApplication.translate("DBManagerPlugin", '(unknown) (<a href="action:extent/get">find out</a>)')
tbl.append( (QApplication.translate("DBManagerPlugin", "Extent:"), extent_str) )

ret.append( HtmlTable( tbl ) )
return ret
Expand Down
88 changes: 44 additions & 44 deletions python/plugins/db_manager/db_plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -63,9 +63,9 @@ def __unicode__(self):
if self.query is None:
return BaseError.__unicode__(self)

msg = u"Error:\n%s" % BaseError.__unicode__(self)
msg = QApplication.translate("DBManagerPlugin", "Error:\n%s") % BaseError.__unicode__(self)
if self.query:
msg += u"\n\nQuery:\n%s" % self.query
msg += QApplication.translate("DBManagerPlugin", "\n\nQuery:\n%s") % self.query
return msg


Expand Down Expand Up @@ -226,34 +226,34 @@ def registerSubPluginActions(self, mainWindow):
load(self, mainWindow)

def registerDatabaseActions(self, mainWindow):
action = QAction("&Re-connect", self)
mainWindow.registerAction( action, "&Database", self.reconnectActionSlot )
action = QAction(QApplication.translate("DBManagerPlugin", "&Re-connect"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Database"), self.reconnectActionSlot )

if self.schemas() != None:
action = QAction("&Create schema", self)
mainWindow.registerAction( action, "&Schema", self.createSchemaActionSlot )
action = QAction("&Delete (empty) schema", self)
mainWindow.registerAction( action, "&Schema", self.deleteSchemaActionSlot )
action = QAction(QApplication.translate("DBManagerPlugin", "&Create schema"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Schema"), self.createSchemaActionSlot )
action = QAction(QApplication.translate("DBManagerPlugin", "&Delete (empty) schema"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Schema"), self.deleteSchemaActionSlot )

action = QAction("Delete selected item", self)
action = QAction(QApplication.translate("DBManagerPlugin", "Delete selected item"), self)
mainWindow.registerAction( action, None, self.deleteActionSlot )
action.setShortcuts(QKeySequence.Delete)

action = QAction(QIcon(":/db_manager/actions/create_table"), "&Create table", self)
mainWindow.registerAction( action, "&Table", self.createTableActionSlot )
action = QAction(QIcon(":/db_manager/actions/edit_table"), "&Edit table", self)
mainWindow.registerAction( action, "&Table", self.editTableActionSlot )
action = QAction(QIcon(":/db_manager/actions/del_table"), "&Delete table/view", self)
mainWindow.registerAction( action, "&Table", self.deleteTableActionSlot )
action = QAction("&Empty table", self)
mainWindow.registerAction( action, "&Table", self.emptyTableActionSlot )
action = QAction(QIcon(":/db_manager/actions/create_table"), QApplication.translate("DBManagerPlugin", "&Create table"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table"), self.createTableActionSlot )
action = QAction(QIcon(":/db_manager/actions/edit_table"), QApplication.translate("DBManagerPlugin", "&Edit table"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table"), self.editTableActionSlot )
action = QAction(QIcon(":/db_manager/actions/del_table"), QApplication.translate("DBManagerPlugin", "&Delete table/view"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table"), self.deleteTableActionSlot )
action = QAction(QApplication.translate("DBManagerPlugin", "&Empty table"), self)
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table"), self.emptyTableActionSlot )

if self.schemas() != None:
action = QAction("&Move to schema", self)
action = QAction(QApplication.translate("DBManagerPlugin", "&Move to schema"), self)
action.setMenu( QMenu(mainWindow) )
invoke_callback = lambda: mainWindow.invokeCallback(self.prepareMenuMoveTableToSchemaActionSlot)
QObject.connect( action.menu(), SIGNAL("aboutToShow()"), invoke_callback )
mainWindow.registerAction( action, "&Table" )
mainWindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table") )


def reconnectActionSlot(self, item, action, parent):
Expand All @@ -269,17 +269,17 @@ def deleteActionSlot(self, item, action, parent):
self.deleteTableActionSlot(item, action, parent)
else:
QApplication.restoreOverrideCursor()
QMessageBox.information(parent, "Sorry", "Cannot delete the selected item.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Cannot delete the selected item."))
QApplication.setOverrideCursor(Qt.WaitCursor)


def createSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, (DBPlugin, Schema, Table)) or item.database() == None:
QMessageBox.information(parent, "Sorry", "No database selected or you are not connected to it.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."))
return
(schema, ok) = QInputDialog.getText(parent, "New schema", "Enter new schema name")
(schema, ok) = QInputDialog.getText(parent, QApplication.translate("DBManagerPlugin", "New schema"), QApplication.translate("DBManagerPlugin", "Enter new schema name"))
if not ok:
return
finally:
Expand All @@ -291,9 +291,9 @@ def deleteSchemaActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Schema):
QMessageBox.information(parent, "Sorry", "Select an empty SCHEMA for deletion.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select an empty SCHEMA for deletion."))
return
res = QMessageBox.question(parent, "hey!", u"Really delete schema %s ?" % item.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete schema %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return
finally:
Expand All @@ -318,7 +318,7 @@ def createSchema(self, name):
def createTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
if not hasattr(item, 'database') or item.database() == None:
QMessageBox.information(parent, "Sorry", "No database selected or you are not connected to it.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "No database selected or you are not connected to it."))
return
from ..dlg_create_table import DlgCreateTable
DlgCreateTable(item, parent).exec_()
Expand All @@ -328,7 +328,7 @@ def editTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, "Sorry", "Select a TABLE for editation.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE for editation."))
return
from ..dlg_table_properties import DlgTableProperties
DlgTableProperties(item, parent).exec_()
Expand All @@ -339,9 +339,9 @@ def deleteTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
QMessageBox.information(parent, "Sorry", "Select a TABLE/VIEW for deletion.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW for deletion."))
return
res = QMessageBox.question(parent, "hey!", u"Really delete table/view %s ?" % item.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete table/view %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return
finally:
Expand All @@ -353,9 +353,9 @@ def emptyTableActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, "Sorry", "Select a TABLE to empty it.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE to empty it."))
return
res = QMessageBox.question(parent, "hey!", u"Really delete all items from table %s ?" % item.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(parent, QApplication.translate("DBManagerPlugin", "hey!"), QApplication.translate("DBManagerPlugin", "Really delete all items from table %s?") % item.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return
finally:
Expand All @@ -375,7 +375,7 @@ def moveTableToSchemaActionSlot(self, item, action, parent, new_schema):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table):
QMessageBox.information(parent, "Sorry", "Select a TABLE/VIEW.")
QMessageBox.information(parent, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Select a TABLE/VIEW."))
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down Expand Up @@ -767,10 +767,10 @@ def runAction(self, action):
parts = action.split('/')
trigger_action = parts[1]

msg = u"Do you want to %s all triggers?" % trigger_action
msg = QApplication.translate("DBManagerPlugin", "Do you want to %s all triggers?") % trigger_action
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, "Table triggers", msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table triggers"), msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand All @@ -787,10 +787,10 @@ def runAction(self, action):
trigger_name = parts[1]
trigger_action = parts[2]

msg = u"Do you want to %s trigger %s?" % (trigger_action, trigger_name)
msg = QApplication.translate("DBManagerPlugin", "Do you want to %s trigger %s?") % (trigger_action, trigger_name)
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, "Table trigger", msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Table trigger"), msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down Expand Up @@ -879,10 +879,10 @@ def runAction(self, action):
parts = action.split('/')
spatialIndex_action = parts[1]

msg = u"Do you want to %s spatial index for field %s?" % ( spatialIndex_action, self.geomColumn )
msg = QApplication.translate("DBManagerPlugin", "Do you want to %s spatial index for field %s?") % ( spatialIndex_action, self.geomColumn )
QApplication.restoreOverrideCursor()
try:
if QMessageBox.question(None, "Spatial Index", msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
if QMessageBox.question(None, QApplication.translate("DBManagerPlugin", "Spatial Index"), msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down Expand Up @@ -992,12 +992,12 @@ def __init__(self, table):
self.name = self.type = self.columns = None

def type2String(self):
if self.type == TableConstraint.TypeCheck: return "Check"
if self.type == TableConstraint.TypePrimaryKey: return "Primary key"
if self.type == TableConstraint.TypeForeignKey: return "Foreign key"
if self.type == TableConstraint.TypeUnique: return "Unique"
if self.type == TableConstraint.TypeExclusion: return "Exclusion"
return 'Unknown'
if self.type == TableConstraint.TypeCheck: return QApplication.translate("DBManagerPlugin", "Check")
if self.type == TableConstraint.TypePrimaryKey: return QApplication.translate("DBManagerPlugin", "Primary key")
if self.type == TableConstraint.TypeForeignKey: return QApplication.translate("DBManagerPlugin", "Foreign key")
if self.type == TableConstraint.TypeUnique: return QApplication.translate("DBManagerPlugin", "Unique")
if self.type == TableConstraint.TypeExclusion: return QApplication.translate("DBManagerPlugin", "Exclusion")
return QApplication.translate("DBManagerPlugin", 'Unknown')

def fields(self):
def fieldFromNum(num, fields):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/postgis/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/postgis/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
56 changes: 28 additions & 28 deletions python/plugins/db_manager/db_plugins/postgis/info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -43,15 +43,15 @@ def generalInfo(self):
self.table.blockSignals(False)

tbl = [
("Relation type:", "View" if self.table.isView else "Table"),
("Owner:", self.table.owner)
(QApplication.translate("DBManagerPlugin", "Relation type:"), QApplication.translate("DBManagerPlugin", "View") if self.table.isView else QApplication.translate("DBManagerPlugin", "Table")),
(QApplication.translate("DBManagerPlugin", "Owner:"), self.table.owner)
]
if self.table.comment:
tbl.append( ("Comment:", self.table.comment) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Comment:"), self.table.comment) )

tbl.extend([
("Pages:", self.table.pages),
("Rows (estimation):", self.table.estimatedRowCount )
(QApplication.translate("DBManagerPlugin", "Pages:"), self.table.pages),
(QApplication.translate("DBManagerPlugin", "Rows (estimation):"), self.table.estimatedRowCount )
])

# privileges
Expand All @@ -60,40 +60,40 @@ def generalInfo(self):
if schema_priv == None:
pass
elif schema_priv[1] == False: # no usage privileges on the schema
tbl.append( ("Privileges:", u"<warning> This user doesn't have usage privileges for this schema!" ) )
tbl.append( (QApplication.translate("DBManagerPlugin", "Privileges:"), QApplication.translate("DBManagerPlugin", "<warning> This user doesn't have usage privileges for this schema!") ) )
else:
table_priv = self.table.database().connector.getTablePrivileges( (self.table.schemaName(), self.table.name) )
privileges = []
if table_priv[0]:
privileges.append("select")

if self.table.rowCount == None or self.table.rowCount >= 0:
tbl.append( ("Rows (counted):", self.table.rowCount if self.table.rowCount != None else 'Unknown (<a href="action:rows/count">find out</a>)') )
tbl.append( (QApplication.translate("DBManagerPlugin", "Rows (counted):"), self.table.rowCount if self.table.rowCount != None else QApplication.translate("DBManagerPlugin", 'Unknown (<a href="action:rows/count">find out</a>)')) )

if table_priv[1]: privileges.append("insert")
if table_priv[2]: privileges.append("update")
if table_priv[3]: privileges.append("delete")
priv_string = u", ".join(privileges) if len(privileges) > 0 else u'<warning> This user has no privileges!'
tbl.append( ("Privileges:", priv_string ) )
priv_string = u", ".join(privileges) if len(privileges) > 0 else QApplication.translate("DBManagerPlugin", '<warning> This user has no privileges!')
tbl.append( (QApplication.translate("DBManagerPlugin", "Privileges:"), priv_string ) )

ret.append( HtmlTable( tbl ) )

if schema_priv != None and schema_priv[1]:
if table_priv[0] and not table_priv[1] and not table_priv[2] and not table_priv[3]:
ret.append( HtmlParagraph( u"<warning> This user has read-only privileges." ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> This user has read-only privileges.") ) )

if not self.table.isView:
if self.table.rowCount != None:
if abs(self.table.estimatedRowCount - self.table.rowCount) > 1 and \
(self.table.estimatedRowCount > 2 * self.table.rowCount or \
self.table.rowCount > 2 * self.table.estimatedRowCount):
ret.append( HtmlParagraph( u"<warning> There's a significant difference between estimated and real row count. " \
'Consider running <a href="action:vacuumanalyze/run">VACUUM ANALYZE</a>.' ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> There's a significant difference between estimated and real row count. "
'Consider running <a href="action:vacuumanalyze/run">VACUUM ANALYZE</a>.') ) )

# primary key defined?
if not self.table.isView:
if len( filter(lambda fld: fld.primaryKey, self.table.fields()) ) <= 0:
ret.append( HtmlParagraph( u"<warning> No primary key defined for this table!" ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> No primary key defined for this table!") ) )

return ret

Expand All @@ -105,23 +105,23 @@ def getSpatialInfo(self):
return

tbl = [
("Library:", info[0]),
("Scripts:", info[3]),
(QApplication.translate("DBManagerPlugin", "Library:"), info[0]),
(QApplication.translate("DBManagerPlugin", "Scripts:"), info[3]),
("GEOS:", info[1]),
("Proj:", info[2])
]
ret.append( HtmlTable( tbl ) )

if info[1] != None and info[1] != info[2]:
ret.append( HtmlParagraph( u"<warning> Version of installed scripts doesn't match version of released scripts!\n" \
"This is probably a result of incorrect PostGIS upgrade." ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> Version of installed scripts doesn't match version of released scripts!\n"
"This is probably a result of incorrect PostGIS upgrade.") ) )

if not self.db.connector.has_geometry_columns:
ret.append( HtmlParagraph( u"<warning> geometry_columns table doesn't exist!\n" \
"This table is essential for many GIS applications for enumeration of tables." ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> geometry_columns table doesn't exist!\n"
"This table is essential for many GIS applications for enumeration of tables.") ) )
elif not self.db.connector.has_geometry_columns_access:
ret.append( HtmlParagraph( u"<warning> This user doesn't have privileges to read contents of geometry_columns table!\n" \
"This table is essential for many GIS applications for enumeration of tables." ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", "<warning> This user doesn't have privileges to read contents of geometry_columns table!\n"
"This table is essential for many GIS applications for enumeration of tables.") ) )

return ret

Expand All @@ -130,7 +130,7 @@ def fieldsDetails(self):
tbl = []

# define the table header
header = ( "#", "Name", "Type", "Length", "Null", "Default" )
header = ( "#", QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Type"), QApplication.translate("DBManagerPlugin", "Length"), QApplication.translate("DBManagerPlugin", "Null"), QApplication.translate("DBManagerPlugin", "Default") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -155,21 +155,21 @@ def triggersDetails(self):

tbl = []
# define the table header
header = ( "Name", "Function", "Type", "Enabled" )
header = ( QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Function"), QApplication.translate("DBManagerPlugin", "Type"), QApplication.translate("DBManagerPlugin", "Enabled") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
for trig in self.table.triggers():
name = u'%(name)s (<a href="action:trigger/%(name)s/%(action)s">%(action)s</a>)' % { "name":trig.name, "action":"delete" }

(enabled, action) = ("Yes", "disable") if trig.enabled else ("No", "enable")
(enabled, action) = (QApplication.translate("DBManagerPlugin", "Yes"), "disable") if trig.enabled else (QApplication.translate("DBManagerPlugin", "No"), "enable")
txt_enabled = u'%(enabled)s (<a href="action:trigger/%(name)s/%(action)s">%(action)s</a>)' % { "name":trig.name, "action":action, "enabled":enabled }

tbl.append( (name, trig.function, trig.type2String(), txt_enabled) )

ret.append( HtmlTable( tbl, {"class":"header"} ) )

ret.append( HtmlParagraph( '<a href="action:triggers/enable">Enable all triggers</a> / <a href="action:triggers/disable">Disable all triggers</a>' ) )
ret.append( HtmlParagraph( QApplication.translate("DBManagerPlugin", '<a href="action:triggers/enable">Enable all triggers</a> / <a href="action:triggers/disable">Disable all triggers</a>') ) )
return ret


Expand All @@ -179,7 +179,7 @@ def rulesDetails(self):

tbl = []
# define the table header
header = ( "Name", "Definition" )
header = ( QApplication.translate("DBManagerPlugin", "Name"), QApplication.translate("DBManagerPlugin", "Definition") )
tbl.append( HtmlTableHeader( header ) )

# add table contents
Expand All @@ -198,7 +198,7 @@ def getTableInfo(self):
if rules_details == None:
pass
else:
ret.append( HtmlSection( 'Rules', rules_details ) )
ret.append( HtmlSection( QApplication.translate("DBManagerPlugin", 'Rules'), rules_details ) )

return ret

Expand Down
18 changes: 10 additions & 8 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -69,7 +69,7 @@ def connect(self, parent=None):
settings.beginGroup( u"/%s/%s" % (self.connectionSettingsKey(), conn_name) )

if not settings.contains( "database" ): # non-existent entry?
raise InvalidDataException( u'there is no defined database connection "%s".' % conn_name )
raise InvalidDataException( self.tr('There is no defined database connection "%s".') % conn_name )

from qgis.core import QgsDataSourceURI
uri = QgsDataSourceURI()
Expand Down Expand Up @@ -110,7 +110,7 @@ def connect(self, parent=None):
if hasCredentialDlg:
(ok, username, password) = QgsCredentials.instance().get(uri.connectionInfo(), username, password, err)
else:
(password, ok) = QInputDialog.getText(parent, u"Enter password", u'Enter password for connection "%s":' % conn_name, QLineEdit.Password)
(password, ok) = QInputDialog.getText(parent, self.tr("Enter password"), self.tr('Enter password for connection "%s":') % conn_name, QLineEdit.Password)

if not ok:
return False
Expand Down Expand Up @@ -165,16 +165,16 @@ def registerDatabaseActions(self, mainWindow):
# add a separator
separator = QAction(self);
separator.setSeparator(True)
mainWindow.registerAction( separator, "&Table" )
mainWindow.registerAction( separator, self.tr("&Table") )

action = QAction("Run &Vacuum Analyze", self)
mainWindow.registerAction( action, "&Table", self.runVacuumAnalyzeActionSlot )
action = QAction(self.tr("Run &Vacuum Analyze"), self)
mainWindow.registerAction( action, self.tr("&Table"), self.runVacuumAnalyzeActionSlot )

def runVacuumAnalyzeActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, Table) or item.isView:
QMessageBox.information(parent, "Sorry", "Select a TABLE for vacuum analyze.")
QMessageBox.information(parent, self.tr("Sorry"), self.tr("Select a TABLE for vacuum analyze."))
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down Expand Up @@ -214,9 +214,11 @@ def runAction(self, action):
rule_action = parts[2]

msg = u"Do you want to %s rule %s?" % (rule_action, rule_name)

QApplication.restoreOverrideCursor()

try:
if QMessageBox.question(None, "Table rule", msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
if QMessageBox.question(None, self.tr("Table rule"), msg, QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
return False
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
# @param mainwindow is the DBManager mainwindow
def load(db, mainwindow):
# add the action to the DBManager menu
action = QAction( QIcon(), "&Versioning", db )
mainwindow.registerAction( action, "&Table", run )
action = QAction( QIcon(), QApplication.translate("DBManagerPlugin", "&Versioning"), db )
mainwindow.registerAction( action, QApplication.translate("DBManagerPlugin", "&Table"), run )


# The run function is called once the user clicks on the action TopoViewer
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/spatialite/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, uri):

self.dbname = uri.database()
if not QFile.exists( self.dbname ):
raise ConnectionError( u'"%s" not found' % self.dbname )
raise ConnectionError( self.tr('"%s" not found') % self.dbname )

try:
self.connection = sqlite.connect( self._connectionInfo() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/db_plugins/spatialite/info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -32,14 +32,14 @@ def __init__(self, db):

def connectionDetails(self):
tbl = [
("Filename:", self.db.connector.dbname)
(self.tr("Filename:"), self.db.connector.dbname)
]
return HtmlTable( tbl )

def generalInfo(self):
info = self.db.connector.getInfo()
tbl = [
("SQLite version", info[0])
(self.tr("SQLite version"), info[0])
]
return HtmlTable( tbl )

Expand Down
8 changes: 4 additions & 4 deletions python/plugins/db_manager/db_plugins/spatialite/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -107,16 +107,16 @@ def sqlResultModel(self, sql, parent):


def registerDatabaseActions(self, mainWindow):
action = QAction("Run &Vacuum", self)
mainWindow.registerAction( action, "&Database", self.runVacuumActionSlot )
action = QAction(self.tr("Run &Vacuum"), self)
mainWindow.registerAction( action, self.tr("&Database"), self.runVacuumActionSlot )

Database.registerDatabaseActions(self, mainWindow)

def runVacuumActionSlot(self, item, action, parent):
QApplication.restoreOverrideCursor()
try:
if not isinstance(item, (DBPlugin, Table)) or item.database() == None:
QMessageBox.information(parent, "Sorry", "No database selected or you are not connected to it.")
QMessageBox.information(parent, self.tr("Sorry"), self.tr("No database selected or you are not connected to it."))
return
finally:
QApplication.setOverrideCursor(Qt.WaitCursor)
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/db_manager/db_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -111,15 +111,15 @@ def contextMenuEvent(self, ev):
menu = QMenu(self)

if isinstance(item, (Table, Schema)):
menu.addAction("Rename", self.rename)
menu.addAction("Delete", self.delete)
menu.addAction(self.tr("Rename"), self.rename)
menu.addAction(self.tr("Delete"), self.delete)

if isinstance(item, Table):
menu.addSeparator()
menu.addAction("Add to QGis canvas", self.addLayer)
menu.addAction(self.tr("Add to QGis canvas"), self.addLayer)

elif isinstance(item, DBPlugin) and item.database() is not None:
menu.addAction("Re-connect", self.reconnect)
menu.addAction(self.tr("Re-connect"), self.reconnect)

if not menu.isEmpty():
menu.exec_(ev.globalPos())
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/db_manager/dlg_add_geometry_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(self, parent=None, table=None, db=None):
def createGeomColumn(self):
""" first check whether everything's fine """
if self.editName.text() == "":
QMessageBox.critical(self, "sorry", "field name must not be empty")
QMessageBox.critical(self, self.tr("Sorry"), self.tr("field name must not be empty"))
return

name = self.editName.text()
Expand All @@ -69,4 +69,3 @@ def createGeomColumn(self):
QApplication.restoreOverrideCursor()

self.accept()

2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_create_constraint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/dlg_create_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -56,7 +56,7 @@ def columnChanged(self):
def createIndex(self):
idx = self.getIndex()
if idx.name == "":
QMessageBox.critical(self, "error", "Please enter some name for the index")
QMessageBox.critical(self, self.tr("Error"), self.tr("Please enter some name for the index"))
return

# now create the index
Expand Down
24 changes: 12 additions & 12 deletions python/plugins/db_manager/dlg_create_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__(self, item, parent=None):
self.fields.setColumnWidth(1,140)
self.fields.setColumnWidth(2,50)

b = QPushButton("&Create")
b = QPushButton(self.tr("&Create"))
self.buttonBox.addButton(b, QDialogButtonBox.ActionRole)

self.connect(self.btnAddField, SIGNAL("clicked()"), self.addField)
Expand Down Expand Up @@ -212,7 +212,7 @@ def deleteField(self):
""" delete selected field """
row = self.selectedField()
if row is None:
QMessageBox.information(self, "sorry", "no field selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("no field selected"))
else:
self.fields.model().removeRows(row,1)

Expand All @@ -222,10 +222,10 @@ def fieldUp(self):
""" move selected field up """
row = self.selectedField()
if row is None:
QMessageBox.information(self, "sorry", "no field selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("no field selected"))
return
if row == 0:
QMessageBox.information(self, "sorry", "field is at top already")
QMessageBox.information(self, self.tr("Sorry"), self.tr("field is at top already"))
return

# take row and reinsert it
Expand All @@ -242,10 +242,10 @@ def fieldDown(self):
""" move selected field down """
row = self.selectedField()
if row is None:
QMessageBox.information(self, "sorry", "no field selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("No field selected"))
return
if row == self.fields.model().rowCount()-1:
QMessageBox.information(self, "sorry", "field is at bottom already")
QMessageBox.information(self, self.tr("Sorry"), self.tr("field is at bottom already"))
return

# take row and reinsert it
Expand All @@ -265,24 +265,24 @@ def createTable(self):
else:
schema = unicode(self.cboSchema.currentText())
if len(schema) == 0:
QMessageBox.information(self, "sorry", "select schema!")
QMessageBox.information(self, self.tr("Sorry"), self.tr("select schema!"))
return

table = unicode(self.editName.text())
if len(table) == 0:
QMessageBox.information(self, "sorry", "enter table name!")
QMessageBox.information(self, self.tr("Sorry"), self.tr("enter table name!"))
return

m = self.fields.model()
if m.rowCount() == 0:
QMessageBox.information(self, "sorry", "add some fields!")
QMessageBox.information(self, self.tr("Sorry"), self.tr("add some fields!"))
return

useGeomColumn = self.chkGeomColumn.isChecked()
if useGeomColumn:
geomColumn = unicode(self.editGeomColumn.text())
if len(geomColumn) == 0:
QMessageBox.information(self, "sorry", "set geometry column name")
QMessageBox.information(self, self.tr("Sorry"), self.tr("set geometry column name"))
return

geomType = self.GEOM_TYPES[ self.cboGeomType.currentIndex() ]
Expand Down Expand Up @@ -314,5 +314,5 @@ def createTable(self):
finally:
QApplication.restoreOverrideCursor()

QMessageBox.information(self, "Good", "everything went fine")
QMessageBox.information(self, self.tr("Good"), self.tr("everything went fine"))

2 changes: 1 addition & 1 deletion python/plugins/db_manager/dlg_db_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
14 changes: 7 additions & 7 deletions python/plugins/db_manager/dlg_export_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -66,7 +66,7 @@ def chooseOutputFile(self):
settings = QSettings()
lastDir = settings.value("/db_manager/lastUsedDir", "")
# ask for a filename
filename = QFileDialog.getSaveFileName(self, "Choose where to save the file", lastDir, "Shapefiles (*.shp)")
filename = QFileDialog.getSaveFileName(self, self.tr("Choose where to save the file"), lastDir, self.tr("Shapefiles") + " (*.shp)")
if filename == "":
return
if filename[:-4] != ".shp":
Expand All @@ -92,21 +92,21 @@ def populateEncodings(self):
def accept(self):
# sanity checks
if self.editOutputFile.text() == "":
QMessageBox.information(self, "Export to file", "Output table name is required")
QMessageBox.information(self, self.tr("Export to file"), self.tr("Output table name is required"))
return

if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
try:
sourceSrid = int(self.editSourceSrid.text())
except ValueError:
QMessageBox.information(self, "Export to file", "Invalid source srid: must be an integer")
QMessageBox.information(self, self.tr("Export to file"), self.tr("Invalid source srid: must be an integer"))
return

if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
try:
targetSrid = int(self.editTargetSrid.text())
except ValueError:
QMessageBox.information(self, "Export to file", "Invalid target srid: must be an integer")
QMessageBox.information(self, self.tr("Export to file"), self.tr("Invalid target srid: must be an integer"))
return

# override cursor
Expand Down Expand Up @@ -156,14 +156,14 @@ def accept(self):
QApplication.restoreOverrideCursor()

if ret != 0:
QMessageBox.warning(self, "Export to file", u"Error %d\n%s" % (ret, errMsg) )
QMessageBox.warning(self, self.tr("Export to file"), self.tr("Error %d\n%s") % (ret, errMsg) )
return

# create spatial index
#if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked():
# self.db.connector.createSpatialIndex( (schema, table), geom )

QMessageBox.information(self, "Export to file", "Export finished.")
QMessageBox.information(self, self.tr("Export to file"), self.tr("Export finished."))
return QDialog.accept(self)


Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/dlg_field_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def onOK(self):
""" first check whether everything's fine """
fld = self.getField(True) # don't change the original copy
if fld.name == "":
QMessageBox.critical(self, "sorry", "field name must not be empty")
QMessageBox.critical(self, self.tr("Sorry"), self.tr("field name must not be empty"))
return
if fld.dataType == "":
QMessageBox.critical(self, "sorry", "field type must not be empty")
QMessageBox.critical(self, self.tr("Sorry"), self.tr("field type must not be empty"))
return

self.accept()
Expand Down
24 changes: 11 additions & 13 deletions python/plugins/db_manager/dlg_import_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -61,8 +61,7 @@ def __init__(self, inLayer, outDb, outUri, parent=None):


def setupWorkingMode(self, mode):
""" hide the widget to select a layer/file if the input layer
is already set """
""" hide the widget to select a layer/file if the input layer is already set """
self.wdgInput.setVisible( mode == self.ASK_FOR_INPUT_MODE )
self.resize( 200, 200 )

Expand Down Expand Up @@ -110,8 +109,7 @@ def populateLayers(self):
self.cboInputLayer.addItem( layer.name(), index )

def deleteInputLayer(self):
""" unset the input layer, then destroy it but only if it was
created from this dialog """
""" unset the input layer, then destroy it but only if it was created from this dialog """
if self.mode == self.ASK_FOR_INPUT_MODE and self.inLayer:
if self.inLayerMustBeDestroyed:
self.inLayer.deleteLater()
Expand All @@ -127,7 +125,7 @@ def chooseInputFile(self):
lastDir = settings.value("/db_manager/lastUsedDir", "")
lastVectorFormat = settings.value("/UI/lastVectorFileFilter", "")
# ask for a filename
filename = QFileDialog.getOpenFileName(self, "Choose the file to import", lastDir, vectorFormats, lastVectorFormat)
filename = QFileDialog.getOpenFileName(self, self.tr("Choose the file to import"), lastDir, vectorFormats, lastVectorFormat)
if filename == "":
return
# store the last used dir and format
Expand Down Expand Up @@ -236,25 +234,25 @@ def accept(self):

# sanity checks
if self.inLayer is None:
QMessageBox.information(self, "Import to database", "Input layer missing or not valid")
QMessageBox.information(self, self.tr("Import to database"), self.tr("Input layer missing or not valid"))
return

if self.cboTable.currentText() == "":
QMessageBox.information(self, "Import to database", "Output table name is required")
QMessageBox.information(self, self.tr("Import to database"), self.tr("Output table name is required"))
return

if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
try:
sourceSrid = self.editSourceSrid.text()
except ValueError:
QMessageBox.information(self, "Import to database", "Invalid source srid: must be an integer")
QMessageBox.information(self, self.tr("Import to database"), self.tr("Invalid source srid: must be an integer"))
return

if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
try:
targetSrid = self.editTargetSrid.text()
except ValueError:
QMessageBox.information(self, "Import to database", "Invalid target srid: must be an integer")
QMessageBox.information(self, self.tr("Import to database"), self.tr("Invalid target srid: must be an integer"))
return

# override cursor
Expand Down Expand Up @@ -321,16 +319,16 @@ def accept(self):

if ret != 0:
output = qgis.gui.QgsMessageViewer()
output.setTitle( "Import to database" )
output.setMessageAsPlainText( u"Error %d\n%s" % (ret, errMsg) )
output.setTitle( self.tr("Import to database") )
output.setMessageAsPlainText( self.tr("Error %d\n%s") % (ret, errMsg) )
output.showMessage()
return

# create spatial index
if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked():
self.db.connector.createSpatialIndex( (schema, table), geom )

QMessageBox.information(self, "Import to database", "Import was successful.")
QMessageBox.information(self, self.tr("Import to database"), self.tr("Import was successful."))
return QDialog.accept(self)


Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/dlg_sql_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -46,7 +46,7 @@ def __init__(self, iface, db, parent=None):
self.defaultLayerName = 'QueryLayer'

settings = QSettings()
self.restoreGeometry(settings.value("/DB_Manager/sqlWindow/geometry"))
self.restoreGeometry(settings.value("/DB_Manager/sqlWindow/geometry", QByteArray(), type=QByteArray))

self.editSql.setAcceptRichText(False)
SqlCompleter(self.editSql, self.db)
Expand Down Expand Up @@ -158,7 +158,7 @@ def executeSql(self):
# set the new model
model = self.db.sqlResultModel( sql, self )
self.viewResult.setModel( model )
self.lblResult.setText("%d rows, %.1f seconds" % (model.affectedRows(), model.secs()))
self.lblResult.setText(self.tr("%d rows, %.1f seconds") % (model.affectedRows(), model.secs()))

except BaseError, e:
QApplication.restoreOverrideCursor()
Expand Down
18 changes: 9 additions & 9 deletions python/plugins/db_manager/dlg_table_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : Oct 13, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -102,7 +102,7 @@ def currentColumn(self):
sel = self.viewFields.selectionModel()
indexes = sel.selectedRows()
if len(indexes) == 0:
QMessageBox.information(self, "sorry", "nothing selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("nothing selected"))
return -1
return indexes[0].row()

Expand Down Expand Up @@ -168,7 +168,7 @@ def deleteColumn(self):
m = self.viewFields.model()
fld = m.getObject(index)

res = QMessageBox.question(self, "are you sure", u"really delete column '%s' ?" % fld.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(self, self.tr("Are you sure"), self.tr("really delete column '%s'?") % fld.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return

Expand Down Expand Up @@ -222,7 +222,7 @@ def deleteConstraint(self):
m = self.viewConstraints.model()
constr = m.getObject(index)

res = QMessageBox.question(self, "are you sure", u"really delete constraint '%s' ?" % constr.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(self, self.tr("Are you sure"), self.tr("really delete constraint '%s'?") % constr.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return

Expand All @@ -242,7 +242,7 @@ def currentConstraint(self):
sel = self.viewConstraints.selectionModel()
indexes = sel.selectedRows()
if len(indexes) == 0:
QMessageBox.information(self, "sorry", "nothing selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("nothing selected"))
return -1
return indexes[0].row()

Expand Down Expand Up @@ -277,10 +277,10 @@ def createIndex(self):
def createSpatialIndex(self):
""" create spatial index for the geometry column """
if self.table.type != self.table.VectorType:
QMessageBox.information(self, "sorry", u"the selected table has no geometry")
QMessageBox.information(self, self.tr("Sorry"), self.tr("The selected table has no geometry"))
return

res = QMessageBox.question(self, "create?", u"create spatial index for field %s?" % self.table.geomColumn, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(self, self.tr("Create?"), self.tr("Create spatial index for field %s?") % self.table.geomColumn, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return

Expand All @@ -302,7 +302,7 @@ def currentIndex(self):
sel = self.viewIndexes.selectionModel()
indexes = sel.selectedRows()
if len(indexes) == 0:
QMessageBox.information(self, "sorry", "nothing selected")
QMessageBox.information(self, self.tr("Sorry"), self.tr("Nothing selected"))
return -1
return indexes[0].row()

Expand All @@ -315,7 +315,7 @@ def deleteIndex(self):
m = self.viewIndexes.model()
idx = m.getObject(index)

res = QMessageBox.question(self, "are you sure", u"really delete index '%s' ?" % idx.name, QMessageBox.Yes | QMessageBox.No)
res = QMessageBox.question(self, self.tr("Are you sure"), self.tr("really delete index '%s'?") % idx.name, QMessageBox.Yes | QMessageBox.No)
if res != QMessageBox.Yes:
return

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down
5 changes: 2 additions & 3 deletions python/plugins/db_manager/info_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -94,7 +94,7 @@ def _clear(self):

def _showPluginInfo(self):
from .db_plugins import getDbPluginErrors
html = u'<div style="background-color:#ffffcc;"><h1>&nbsp;DB Manager</h1></div>'
html = u'<div style="background-color:#ffffcc;"><h1>&nbsp;' + self.tr("DB Manager") + '</h1></div>'
html += '<div style="margin-left:8px;">'
for msg in getDbPluginErrors():
html += u"<p>%s" % msg
Expand Down Expand Up @@ -163,4 +163,3 @@ def setHtml(self, html):

#print ">>>>>\n", html, "\n<<<<<<"
return QTextBrowser.setHtml(self, html)

4 changes: 2 additions & 2 deletions python/plugins/db_manager/layer_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -92,7 +92,7 @@ def _loadTablePreview(self, table, limit=False):
if limit and table.rowCount > 1000:
uniqueField = table.getValidQGisUniqueFields(True)
if uniqueField == None:
QMessageBox.warning(self, "Sorry", "Unable to find a valid unique field")
QMessageBox.warning(self, QApplication.translate("DBManagerPlugin", "Sorry"), QApplication.translate("DBManagerPlugin", "Unable to find a valid unique field"))
return

uri = table.database().uri()
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/db_manager/table_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
/***************************************************************************
Name : DB Manager
Description : Database manager plugin for QuantumGIS
Description : Database manager plugin for QGIS
Date : May 23, 2011
copyright : (C) 2011 by Giuseppe Sucameli
email : brush.tyler@gmail.com
Expand Down Expand Up @@ -36,7 +36,7 @@ def __init__(self, parent=None):
self.dirty = False

# allow to copy results
copyAction = QAction("copy", self)
copyAction = QAction(QApplication.translate("DBManagerPlugin", "Copy"), self)
self.addAction( copyAction )
copyAction.setShortcuts(QKeySequence.Copy)
QObject.connect(copyAction, SIGNAL("triggered()"), self.copySelectedResults)
Expand Down