Skip to content

Commit d6171aa

Browse files
alexbruytimlinux
authored andcommitted
more translatable strings in OSM plugin
1 parent 59225ad commit d6171aa

9 files changed

+81
-95
lines changed

python/plugins/osm/OsmAddRelationDlg.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def __init__(self, plugin, newRelationFirstMember=None, relationToEdit=None):
6161
# we are editing existing relation
6262
self.editing = True
6363
self.relId = relationToEdit
64-
self.createRelButton.setText("Save")
65-
self.setWindowTitle("Edit OSM relation")
64+
self.createRelButton.setText( self.tr("Save") )
65+
self.setWindowTitle( self.tr("Edit OSM relation") )
6666
else:
6767
self.editing = False
6868
# we are adding new relation
@@ -790,18 +790,14 @@ def __showTypeInfo(self):
790790
info = ""
791791

792792
if typeName=="boundary":
793-
info = "for grouping boundaries and marking enclaves / exclaves"
793+
info = QCoreApplication.translate( "OsmAddRelationDlg", "for grouping boundaries and marking enclaves / exclaves" )
794794
elif typeName=="multipolygon":
795-
info = "to put holes into areas (might have to be renamed, see article)"
795+
info = QCoreApplication.translate( "OsmAddRelationDlg", "to put holes into areas (might have to be renamed, see article)" )
796796
elif typeName=="restriction":
797-
info = "any kind of turn restriction"
797+
info = QCoreApplication.translate( "OsmAddRelationDlg", "any kind of turn restriction" )
798798
elif typeName=="route":
799-
info = "like bus routes, cycle routes and numbered highways"
799+
info = QCoreApplication.translate( "OsmAddRelationDlg", "like bus routes, cycle routes and numbered highways" )
800800
elif typeName=="enforcement":
801-
info = "traffic enforcement devices; speed cameras, redlight cameras, weight checks, ..."
802-
803-
QMessageBox.information(self, self.tr("OSM Information")
804-
,self.tr(info))
805-
806-
801+
info = QCoreApplication.translate( "OsmAddRelationDlg", "traffic enforcement devices; speed cameras, redlight cameras, weight checks, ..." )
807802

803+
QMessageBox.information(self, self.tr("OSM Information"), info)

python/plugins/osm/OsmDownloadDlg.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def httpDone(self,error):
262262
# and tell user (if the download wasn't cancelled by user)
263263
if self.errMessage != "__cancel__":
264264
if self.errMessage==None:
265-
self.errMessage="Check your internet connection"
265+
self.errMessage=QCoreApplication.translate( "OsmDownloadDlg", "Check your internet connection" )
266266
QMessageBox.information(self, self.tr("OSM Download Error")
267267
,self.tr("Download failed: %1.").arg(self.errMessage))
268268
return
@@ -302,7 +302,7 @@ def showChooseDirectoryDialog(self):
302302
"""
303303

304304
# display file open dialog and get absolute path to selected directory
305-
fileSelected = QFileDialog.getSaveFileName(self, "Choose file to save","download.osm", "OSM Files (*.osm)");
305+
fileSelected = QFileDialog.getSaveFileName(self, self.tr("Choose file to save"),"download.osm", self.tr("OSM Files (*.osm)") );
306306
# insert selected directory path into line edit control
307307
if not fileSelected.isNull():
308308
self.destdirLineEdit.setText(fileSelected)
@@ -339,7 +339,7 @@ def autoLoadClicked(self):
339339

340340
def showExtentHelp(self):
341341
"""Function is called after clicking on Help button.
342-
It shows basic information on downloading.
342+
It shows basic information on downloading.
343343
"""
344344

345345
mb=QMessageBox()
@@ -464,6 +464,3 @@ def disconnectDlgSignals(self):
464464
self.disconnect(self.downloadButton, SIGNAL("clicked()"), self.downloadFile)
465465
self.disconnect(self.choosedirButton, SIGNAL("clicked()"), self.showChooseDirectoryDialog)
466466
self.disconnect(self.autoLoadCheckBox, SIGNAL("clicked()"), self.autoLoadClicked)
467-
468-
469-

python/plugins/osm/OsmFeatureDW.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ def __startMovingFeature(self):
622622

623623
# clear dockwidget
624624
self.clear()
625-
self.plugin.iface.mainWindow().statusBar().showMessage("Snapping ON. Hold Ctrl to disable it.")
625+
self.plugin.iface.mainWindow().statusBar().showMessage(self.tr("Snapping ON. Hold Ctrl to disable it."))
626626

627627
self.mapTool=OsmMoveMT(self.plugin)
628628
self.plugin.canvas.setMapTool(self.mapTool)
@@ -639,7 +639,7 @@ def __startPointCreation(self):
639639
if self.activeEditButton==self.createPointButton:
640640
return
641641

642-
self.plugin.iface.mainWindow().statusBar().showMessage("Snapping ON. Hold Ctrl to disable it.")
642+
self.plugin.iface.mainWindow().statusBar().showMessage(self.tr("Snapping ON. Hold Ctrl to disable it."))
643643

644644
self.mapTool=OsmCreatePointMT(self.plugin)
645645
self.plugin.canvas.setMapTool(self.mapTool)
@@ -656,7 +656,7 @@ def __startLineCreation(self):
656656
if self.activeEditButton==self.createLineButton:
657657
return
658658

659-
self.plugin.iface.mainWindow().statusBar().showMessage("Snapping ON. Hold Ctrl to disable it.")
659+
self.plugin.iface.mainWindow().statusBar().showMessage(self.tr("Snapping ON. Hold Ctrl to disable it."))
660660

661661
self.mapTool=OsmCreateLineMT(self.plugin)
662662
self.plugin.canvas.setMapTool(self.mapTool)
@@ -673,7 +673,7 @@ def __startPolygonCreation(self):
673673
if self.activeEditButton==self.createPolygonButton:
674674
return
675675

676-
self.plugin.iface.mainWindow().statusBar().showMessage("Snapping ON. Hold Ctrl to disable it.")
676+
self.plugin.iface.mainWindow().statusBar().showMessage(self.tr("Snapping ON. Hold Ctrl to disable it."))
677677

678678
self.mapTool=OsmCreatePolygonMT(self.plugin)
679679
self.plugin.canvas.setMapTool(self.mapTool)
@@ -770,7 +770,7 @@ def removeSelectedTags(self):
770770
elif self.featureType=='Relation':
771771
self.plugin.dbm.changeRelationStatus(self.feature.id(),'N','U')
772772

773-
# perform tag removing
773+
# perform tag removing
774774
self.plugin.dbm.removeTag(self.feature.id(),self.featureType,key.toAscii().data())
775775

776776
self.tagTable.removeRow(ix)
@@ -1254,9 +1254,7 @@ def __urDetailsChecked(self):
12541254

12551255
if self.urDetailsButton.isChecked():
12561256
self.plugin.undoredo.show()
1257-
self.urDetailsButton.setToolTip("Hide OSM Edit History")
1257+
self.urDetailsButton.setToolTip(self.tr("Hide OSM Edit History"))
12581258
else:
12591259
self.plugin.undoredo.hide()
1260-
self.urDetailsButton.setToolTip("Show OSM Edit History")
1261-
1262-
1260+
self.urDetailsButton.setToolTip(self.tr("Show OSM Edit History"))

python/plugins/osm/OsmImportDlg.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ def onOK(self):
101101

102102
layer = QgsMapLayerRegistry.instance().mapLayer(layerId)
103103
if layer is None:
104-
QMessageBox.warning(self, "Layer doesn't exist", "The selected layer doesn't exist anymore!")
104+
QMessageBox.warning(self, self.tr("Layer doesn't exist"), self.tr("The selected layer doesn't exist anymore!"))
105105
return
106106

107-
self.progress = QProgressDialog("Importing features...", "Cancel", 0, 100, self)
107+
self.progress = QProgressDialog(self.tr("Importing features..."), self.tr("Cancel"), 0, 100, self)
108108
self.progress.setWindowModality(Qt.WindowModal)
109109

110110
self.nodes = { }
@@ -135,7 +135,7 @@ def onOK(self):
135135
self.dbm.recacheAffectedNow(self.affected)
136136
self.plugin.canvas.refresh()
137137

138-
QMessageBox.information(self, "Import", "Import has been completed.")
138+
QMessageBox.information(self, self.tr("Import"), self.tr("Import has been completed."))
139139
self.accept()
140140

141141

@@ -249,4 +249,3 @@ def extractPolygon(self, polygon):
249249
dp = dummyPoint(p[0])
250250
self.nodes[dp] = dummyFeat(nodeId)
251251
nodeId -= 1
252-

python/plugins/osm/OsmLoadDlg.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def showOpenFileDialog(self):
8585
lastDir=settings.value("/OSM_Plugin/lastDir", QVariant(QString())).toString()
8686

8787
# display file open dialog and get absolute path to selected file
88-
fileSelected=QFileDialog.getOpenFileName(self,"Choose an Open Street Map file",lastDir,"OSM Files (*.osm)");
88+
fileSelected=QFileDialog.getOpenFileName(self,self.tr("Choose an Open Street Map file"),lastDir,self.tr("OSM Files (*.osm)"));
8989
# insert OSM file path into line edit control
9090
if not fileSelected.isNull():
9191
self.OSMFileEdit.setText(fileSelected)
@@ -108,7 +108,7 @@ def onOK(self):
108108
self.fname = self.OSMFileEdit.text()
109109

110110
if self.fname=='':
111-
QMessageBox.information(self, "OSM Load", QString("Please enter path to OSM data file."))
111+
QMessageBox.information(self, self.tr("OSM Load"),self.tr("Please enter path to OSM data file."))
112112
self.buttonBox.setEnabled(True)
113113
return
114114

@@ -117,7 +117,7 @@ def onOK(self):
117117
basename = osmfile.baseName()
118118

119119
if not osmfile.exists():
120-
QMessageBox.information(self, "OSM Load", QString("Path to OSM file is invalid: %1.").arg(self.fname))
120+
QMessageBox.information(self, self.tr("OSM Load"), self.tr("Path to OSM file is invalid: %1.").arg(self.fname))
121121
return
122122

123123
fLoaded=self.filesLoaded()
@@ -126,11 +126,11 @@ def onOK(self):
126126
curDB=self.dbm.currentKey
127127

128128
if basename in fLoaded and newDB<>curDB:
129-
QMessageBox.information(self, "Error", QString("Layers of OSM file \"%1\" are loaded already.").arg(self.fname))
129+
QMessageBox.information(self, self.tr("Error"), self.tr("Layers of OSM file \"%1\" are loaded already.").arg(self.fname))
130130
return
131131

132-
if replacing:
133-
# remove layers of current data first
132+
if replacing:
133+
# remove layers of current data first
134134
QgsMapLayerRegistry.instance().removeMapLayer(self.canvas.currentLayer().id(),True)
135135

136136
if self.chkCustomRenderer.isChecked():
@@ -162,7 +162,7 @@ def onOK(self):
162162
polygonLayer=None
163163
return
164164
if not polygonLayer.isValid():
165-
QMessageBox.information(self,"Error",QString("Failed to load polygon layer."))
165+
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load polygon layer."))
166166
return
167167

168168
if self.chkCustomRenderer.isChecked():
@@ -176,7 +176,7 @@ def onOK(self):
176176
lineLayer=None
177177
return
178178
if not lineLayer.isValid():
179-
QMessageBox.information(self,"Error",QString("Failed to load line layer."))
179+
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load line layer."))
180180
return
181181

182182
if self.chkCustomRenderer.isChecked():
@@ -190,7 +190,7 @@ def onOK(self):
190190
pointLayer=None
191191
return
192192
if not pointLayer.isValid():
193-
QMessageBox.information(self,"Error",QString("Failed to load point layer."))
193+
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load point layer."))
194194
return
195195

196196
if self.chkCustomRenderer.isChecked():
@@ -231,7 +231,7 @@ def setCustomRenderer(self, layer):
231231
self.emit( SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer )
232232
QObject.disconnect( self, SIGNAL( "setRenderer(QgsVectorLayer *)" ), layer.dataProvider(), SLOT( "setRenderer( QgsVectorLayer * )" ) )
233233
else:
234-
QMessageBox.information(self, "OSM Load", QString("Could not connect to setRenderer signal."))
234+
QMessageBox.information(self, self.tr("OSM Load"), self.tr("Could not connect to setRenderer signal."))
235235

236236
def filesLoaded(self):
237237
"""Function returns list of keys of all currently loaded vector layers.
@@ -303,11 +303,9 @@ def event(self, e):
303303
QObject.disconnect(self.progress,SIGNAL("canceled()"),self.cancelLoading)
304304
self.progress.close()
305305
self.progress = None
306-
QMessageBox.information(self,"Error",QString("Failed to load layers: %1")
306+
QMessageBox.information(self,self.tr("Error"),self.tr("Failed to load layers: %1")
307307
.arg(self.property("osm_failure").toString()))
308308
self.buttonBox.setEnabled(True)
309309

310310
qApp.processEvents()
311311
return QDialog.event(self,e)
312-
313-

python/plugins/osm/OsmPlugin.py

+31-28
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,28 @@ def initGui(self):
7373

7474
# create action for loading OSM file
7575
self.actionLoad=QAction(QIcon(":/plugins/osm_plugin/images/osm_load.png")
76-
,"Load OSM from file", self.iface.mainWindow())
77-
self.actionLoad.setWhatsThis("Load OpenStreetMap from file")
76+
,QCoreApplication.translate( "OsmPlugin", "Load OSM from file"), self.iface.mainWindow())
77+
self.actionLoad.setWhatsThis( QCoreApplication.translate( "OsmPlugin", "Load OpenStreetMap from file") )
7878
# create action for import of a layer into OSM
7979
self.actionImport=QAction(QIcon(":/plugins/osm_plugin/images/osm_import.png")
80-
,"Import data from a layer", self.iface.mainWindow())
81-
self.actionImport.setWhatsThis("Import data from a layer to OpenStreetMap")
80+
,QCoreApplication.translate( "OsmPlugin", "Import data from a layer"), self.iface.mainWindow())
81+
self.actionImport.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Import data from a layer to OpenStreetMap") )
8282
# create action for saving OSM file
8383
self.actionSave=QAction(QIcon(":/plugins/osm_plugin/images/osm_save.png")
84-
,"Save OSM to file", self.iface.mainWindow())
85-
self.actionSave.setWhatsThis("Save OpenStreetMap to file")
84+
,QCoreApplication.translate( "OsmPlugin", "Save OSM to file"), self.iface.mainWindow())
85+
self.actionSave.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Save OpenStreetMap to file") )
8686
# create action for OSM data downloading
8787
self.actionDownload=QAction(QIcon(":/plugins/osm_plugin/images/osm_download.png")
88-
,"Download OSM data", self.iface.mainWindow())
89-
self.actionDownload.setWhatsThis("Download OpenStreetMap data")
88+
,QCoreApplication.translate( "OsmPlugin", "Download OSM data"), self.iface.mainWindow())
89+
self.actionDownload.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Download OpenStreetMap data") )
9090
# create action for OSM data downloading
9191
self.actionUpload=QAction(QIcon(":/plugins/osm_plugin/images/osm_upload.png")
92-
,"Upload OSM data", self.iface.mainWindow())
93-
self.actionUpload.setWhatsThis("Upload OpenStreetMap data")
92+
,QCoreApplication.translate( "OsmPlugin", "Upload OSM data"), self.iface.mainWindow())
93+
self.actionUpload.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Upload OpenStreetMap data") )
9494
# create action for OSM dockable window
9595
self.actionDockWidget=QAction(QIcon(":/plugins/osm_plugin/images/osm_featureManager.png")
96-
,"Show/Hide OSM Feature Manager",self.iface.mainWindow())
97-
self.actionDockWidget.setWhatsThis("Show/Hide OpenStreetMap Feature Manager")
96+
,QCoreApplication.translate( "OsmPlugin", "Show/Hide OSM Feature Manager"),self.iface.mainWindow())
97+
self.actionDockWidget.setWhatsThis(QCoreApplication.translate( "OsmPlugin", "Show/Hide OpenStreetMap Feature Manager") )
9898
self.actionDockWidget.setCheckable(True)
9999

100100
# connect new action to plugin function - when action is triggered
@@ -193,7 +193,8 @@ def loadOsmFromFile(self):
193193

194194
# sanity check whether we're able to load osm data
195195
if 'osm' not in QgsProviderRegistry.instance().providerList():
196-
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
196+
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
197+
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
197198
return
198199

199200
# show modal dialog with OSM file selection
@@ -222,13 +223,14 @@ def saveOsmToFile(self):
222223
"""
223224

224225
if 'osm' not in QgsProviderRegistry.instance().providerList():
225-
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
226+
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
227+
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
226228
return
227229

228230
if not self.dbm.currentKey:
229-
QMessageBox.information(QWidget(), QString("OSM Save to file")
230-
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
231-
Please change this situation first, because OSM Plugin doesn't know what to save.")
231+
QMessageBox.information(QWidget(), QCoreApplication.translate( "OsmPlugin", "OSM Save to file"),
232+
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
233+
Please change this situation first, because OSM Plugin doesn't know what to save.") )
232234
return
233235

234236
# show modal dialog with OSM file selection
@@ -247,7 +249,8 @@ def downloadOsmData(self):
247249
"""
248250

249251
if 'osm' not in QgsProviderRegistry.instance().providerList():
250-
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
252+
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry" ),
253+
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
251254
return
252255

253256
self.dlgDownload=OsmDownloadDlg(self)
@@ -299,9 +302,9 @@ def uploadOsmData(self):
299302

300303
# first check if there are some data; if not upload doesn't have sense
301304
if not self.dbm.currentKey:
302-
QMessageBox.information(QWidget(), QString("OSM Upload")
303-
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
304-
Please change this situation first, because OSM Plugin doesn't know what to upload.")
305+
QMessageBox.information(QWidget(), QCoreApplication.translate( "OsmPlugin", "OSM Upload"),
306+
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
307+
Please change this situation first, because OSM Plugin doesn't know what to upload.") )
305308
return
306309

307310
self.dlgUpload=OsmUploadDlg(self)
@@ -316,18 +319,20 @@ def importData(self):
316319
"""
317320

318321
if 'osm' not in QgsProviderRegistry.instance().providerList():
319-
QMessageBox.critical(None, "Sorry", "You don't have OSM provider installed!")
322+
QMessageBox.critical(None, QCoreApplication.translate( "OsmPlugin", "Sorry"),
323+
QCoreApplication.translate( "OsmPlugin", "You don't have OSM provider installed!") )
320324
return
321325

322326
if self.dbm.currentKey is None:
323-
QMessageBox.information(self.iface.mainWindow(), "OSM Import"
324-
,"No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
325-
Please change this situation first, because OSM Plugin doesn't know what layer will be destination of the import.")
327+
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate( "OsmPlugin", "OSM Import"),
328+
QCoreApplication.translate( "OsmPlugin", "No OSM data are loaded/downloaded or no OSM layer is selected in Layers panel. \
329+
Please change this situation first, because OSM Plugin doesn't know what layer will be destination of the import.") )
326330
return
327331

328332
dlg=OsmImportDlg(self)
329333
if dlg.cboLayer.count()==0:
330-
QMessageBox.information(self.iface.mainWindow(), "OSM Import", "There are currently no available vector layers.")
334+
QMessageBox.information(self.iface.mainWindow(), QCoreApplication.translate( "OsmPlugin", "OSM Import"),
335+
QCoreApplication.translate( "OsmPlugin", "There are currently no available vector layers.") )
331336
return
332337

333338
dlg.exec_()
@@ -367,5 +372,3 @@ def __ofVisibilityChanged(self):
367372
self.actionDockWidget.setChecked(True)
368373
else:
369374
self.actionDockWidget.setChecked(False)
370-
371-

0 commit comments

Comments
 (0)