Skip to content

Commit bd13693

Browse files
committed
[processing] make bunch of strings translatable (sorry translators)
1 parent f935316 commit bd13693

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+331
-317
lines changed

python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def getPostProcessingErrorMessage(self, wrongLayers):
521521
for layer in wrongLayers:
522522
html += self.tr('<li>%s: <font size=3 face="Courier New" '
523523
'color="#ff0000">%s</font></li>\n') % \
524-
(layer.description, layer.value)
524+
(layer.description, layer.value)
525525
html += self.tr('</ul><p>The above files could not be opened, which '
526526
'probably indicates that they were not correctly '
527527
'produced by the executed algorithm</p>'
@@ -532,4 +532,4 @@ def getPostProcessingErrorMessage(self, wrongLayers):
532532
def tr(self, string, context=''):
533533
if context == '':
534534
context = 'GeoAlgorithm'
535-
return QtCore.QCoreApplication.translate(context, string)
535+
return QCoreApplication.translate(context, string)

python/plugins/processing/core/Processing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def addProvider(provider, updateList=False):
9595
Processing.updateAlgsList()
9696
except:
9797
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
98-
self.tr('Could not load provider: %s\n%s')
99-
% (provider.getDescription(), unicode(sys.exc_info()[1])))
98+
self.tr('Could not load provider: %s\n%s')
99+
% (provider.getDescription(), unicode(sys.exc_info()[1])))
100100
Processing.removeProvider(provider)
101101

102102
@staticmethod
@@ -284,16 +284,16 @@ def runAlgorithm(algOrName, onFinish, *args):
284284
print 'Error: Wrong parameter value %s for parameter %s.' \
285285
% (value, name)
286286
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
287-
self.tr("Error in %s. Wrong parameter value %s for parameter %s.") \
287+
self.tr('Error in %s. Wrong parameter value %s for parameter %s.') \
288288
% (alg.name, value, name))
289289
return
290290
# fill any missing parameters with default values if allowed
291291
for param in alg.parameters:
292292
if param.name not in setParams:
293293
if not param.setValue(None):
294-
print ("Error: Missing parameter value for parameter %s." % (param.name))
294+
print ('Error: Missing parameter value for parameter %s.' % (param.name))
295295
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
296-
self.tr("Error in %s. Missing parameter value for parameter %s.") \
296+
self.tr('Error in %s. Missing parameter value for parameter %s.') \
297297
% (alg.name, param.name))
298298
return
299299
else:

python/plugins/processing/core/parameters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def getFileFilter(self):
364364
else:
365365
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
366366
for i in range(len(exts)):
367-
exts[i] = self.tr('%s files(*.%s', 'ParameterMultipleInput') % (exts[i].upper(), exts[i].lower())
367+
exts[i] = self.tr('%s files(*.%s)', 'ParameterMultipleInput') % (exts[i].upper(), exts[i].lower())
368368
return ';;'.join(exts)
369369

370370

@@ -495,7 +495,7 @@ def setValue(self, obj):
495495
def getFileFilter(self):
496496
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
497497
for i in range(len(exts)):
498-
exts[i] = self.tr('%s files(*.%s', 'ParameterRaster') % (exts[i].upper(), exts[i].lower())
498+
exts[i] = self.tr('%s files(*.%s)', 'ParameterRaster') % (exts[i].upper(), exts[i].lower())
499499
return ';;'.join(exts)
500500

501501

@@ -612,7 +612,7 @@ def getSafeExportedTable(self):
612612
def getFileFilter(self):
613613
exts = ['csv', 'dbf']
614614
for i in range(len(exts)):
615-
exts[i] = self.tr('%s files(*.%s', 'ParameterTable') % (exts[i].upper(), exts[i].lower())
615+
exts[i] = self.tr('%s files(*.%s)', 'ParameterTable') % (exts[i].upper(), exts[i].lower())
616616
return ';;'.join(exts)
617617

618618

@@ -721,5 +721,5 @@ def getSafeExportedLayer(self):
721721
def getFileFilter(self):
722722
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
723723
for i in range(len(exts)):
724-
exts[i] = self.tr('%s files(*.%s', 'ParameterVector') % (exts[i].upper(), exts[i].lower())
724+
exts[i] = self.tr('%s files(*.%s)', 'ParameterVector') % (exts[i].upper(), exts[i].lower())
725725
return ';;'.join(exts)

python/plugins/processing/gui/AlgorithmExecutionDialog.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, alg, mainWidget):
6464
self.buttonBox.setOrientation(Qt.Horizontal)
6565
self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
6666
self.runButton = QPushButton()
67-
self.runButton.setText('Run')
67+
self.runButton.setText(self.tr('Run'))
6868
self.buttonBox.addButton(self.runButton, QDialogButtonBox.ActionRole)
6969
self.runButton.clicked.connect(self.accept)
7070
self.setWindowTitle(self.alg.name)
@@ -78,11 +78,11 @@ def __init__(self, alg, mainWidget):
7878
self.verticalLayout.setMargin(9)
7979
self.tabWidget = QTabWidget()
8080
self.tabWidget.setMinimumWidth(300)
81-
self.tabWidget.addTab(self.mainWidget, 'Parameters')
81+
self.tabWidget.addTab(self.mainWidget, self.tr('Parameters'))
8282
self.verticalLayout.addWidget(self.tabWidget)
8383
self.logText = QTextEdit()
8484
self.logText.readOnly = True
85-
self.tabWidget.addTab(self.logText, 'Log')
85+
self.tabWidget.addTab(self.logText, self.tr('Log'))
8686
self.webView = QWebView()
8787
html = None
8888
url = None
@@ -93,15 +93,16 @@ def __init__(self, alg, mainWidget):
9393
else:
9494
url = QUrl(help)
9595
else:
96-
html = '<h2>Sorry, no help is available for this \
97-
algorithm.</h2>'
96+
html = self.tr('<h2>Sorry, no help is available for this '
97+
'algorithm.</h2>')
9898
try:
9999
if html:
100100
self.webView.setHtml(html)
101101
elif url:
102102
self.webView.load(url)
103103
except:
104-
self.webView.setHtml('<h2>Could not open help file :-( </h2>')
104+
self.webView.setHtml(
105+
self.tr('<h2>Could not open help file :-( </h2>'))
105106
self.tabWidget.addTab(self.webView, 'Help')
106107
self.verticalLayout.addWidget(self.progressLabel)
107108
self.verticalLayout.addWidget(self.progress)
@@ -195,17 +196,18 @@ def accept(self):
195196
try:
196197
self.setParamValues()
197198
if checkCRS and not self.alg.checkInputCRS():
198-
reply = QMessageBox.question(self, "Unmatching CRS's",
199-
'Layers do not all use the same CRS.\n'
200-
+ 'This can cause unexpected results.\n'
201-
+ 'Do you want to continue?',
202-
QMessageBox.Yes | QMessageBox.No,
203-
QMessageBox.No)
199+
reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
200+
self.tr('Layers do not all use the same CRS. This can '
201+
'cause unexpected results.\nDo you want to'
202+
'continue?'),
203+
QMessageBox.Yes | QMessageBox.No,
204+
QMessageBox.No)
204205
if reply == QMessageBox.No:
205206
return
206207
msg = self.alg.checkParameterValuesBeforeExecuting()
207208
if msg:
208-
QMessageBox.warning(self, 'Unable to execute algorithm', msg)
209+
QMessageBox.warning(
210+
self, self.tr('Unable to execute algorithm'), msg)
209211
return
210212
self.runButton.setEnabled(False)
211213
self.buttonBox.button(
@@ -221,10 +223,11 @@ def accept(self):
221223

222224
self.tabWidget.setCurrentIndex(1) # Log tab
223225
self.progress.setMaximum(0)
224-
self.progressLabel.setText('Processing algorithm...')
226+
self.progressLabel.setText(self.tr('Processing algorithm...'))
225227
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
226228

227-
self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name)
229+
self.setInfo(
230+
self.tr('<b>Algorithm %s starting...</b>') % self.alg.name)
228231
# make sure the log tab is visible before executing the algorithm
229232
try:
230233
self.repaint()
@@ -254,12 +257,13 @@ def accept(self):
254257
palette = ex.widget.palette()
255258
palette.setColor(QPalette.Base, QColor(255, 255, 0))
256259
ex.widget.setPalette(palette)
257-
self.progressLabel.setText('<b>Missing parameter value: '
258-
+ ex.parameter.description + '</b>')
260+
self.progressLabel.setText(
261+
self.tr('<b>Missing parameter value: %s</b>' % ex.parameter.description))
259262
return
260263
except:
261-
QMessageBox.critical(self, 'Unable to execute algorithm',
262-
'Wrong or missing parameter values')
264+
QMessageBox.critical(self,
265+
self.tr('Unable to execute algorithm'),
266+
self.tr('Wrong or missing parameter values'))
263267

264268
def finish(self):
265269
keepOpen = ProcessingConfig.getSetting(
@@ -274,8 +278,9 @@ def finish(self):
274278
else:
275279
self.resetGUI()
276280
if self.alg.getHTMLOutputsCount() > 0:
277-
self.setInfo('HTML output has been generated by this '
278-
+ 'algorithm.\nOpen the results dialog to check it.')
281+
self.setInfo(
282+
self.tr('HTML output has been generated by this algorithm.'
283+
'\nOpen the results dialog to check it.'))
279284

280285
def error(self, msg):
281286
QApplication.restoreOverrideCursor()

python/plugins/processing/gui/BatchInputSelectionPanel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ def showPopupMenu(self):
6262
popupmenu = QtGui.QMenu()
6363
if not (isinstance(self.param, ParameterMultipleInput)
6464
and self.param.datatype == ParameterMultipleInput.TYPE_FILE):
65-
selectLayerAction = QtGui.QAction('Select from open layers',
65+
selectLayerAction = QtGui.QAction(self.tr('Select from open layers'),
6666
self.pushButton)
6767
selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
6868
popupmenu.addAction(selectLayerAction)
69-
selectFileAction = QtGui.QAction('Select from filesystem',
69+
selectFileAction = QtGui.QAction(self.tr('Select from filesystem'),
7070
self.pushButton)
7171
selectFileAction.triggered.connect(self.showFileSelectionDialog)
7272
popupmenu.addAction(selectFileAction)
@@ -114,8 +114,8 @@ def showFileSelectionDialog(self):
114114
else:
115115
path = ''
116116

117-
ret = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', path,
118-
'All files(*.*);;' + self.param.getFileFilter())
117+
ret = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'), path,
118+
self.tr('All files(*.*);;') + self.param.getFileFilter())
119119
if ret:
120120
files = list(ret)
121121
if len(files) == 1:

python/plugins/processing/gui/BatchOutputSelectionPanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, output, alg, row, col, batchDialog):
6363

6464
def showSelectionDialog(self):
6565
filefilter = self.output.getFileFilter(self.alg)
66-
filename = QtGui.QFileDialog.getSaveFileName(self, 'Save file', '',
66+
filename = QtGui.QFileDialog.getSaveFileName(self, self.tr('Save file'), '',
6767
filefilter)
6868
if filename:
6969
filename = unicode(filename)

python/plugins/processing/gui/BatchProcessingDialog.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@ def __init__(self, alg):
6363
AlgorithmExecutionDialog.__init__(self, alg, self.table)
6464
self.setWindowModality(1)
6565
self.resize(800, 500)
66-
self.setWindowTitle('Batch Processing - ' + self.alg.name)
66+
self.setWindowTitle(self.tr('Batch Processing - %s') % self.alg.name)
6767
for param in self.alg.parameters:
6868
if param.isAdvanced:
6969
self.advancedButton = QtGui.QPushButton()
70-
self.advancedButton.setText('Show advanced parameters')
70+
self.advancedButton.setText(self.tr('Show advanced parameters'))
7171
self.advancedButton.setMaximumWidth(150)
7272
self.buttonBox.addButton(self.advancedButton,
7373
QtGui.QDialogButtonBox.ActionRole)
7474
self.advancedButton.clicked.connect(
7575
self.showAdvancedParametersClicked)
7676
break
7777
self.addRowButton = QtGui.QPushButton()
78-
self.addRowButton.setText('Add row')
78+
self.addRowButton.setText(self.tr('Add row'))
7979
self.buttonBox.addButton(self.addRowButton,
8080
QtGui.QDialogButtonBox.ActionRole)
8181
self.deleteRowButton = QtGui.QPushButton()
82-
self.deleteRowButton.setText('Delete row')
82+
self.deleteRowButton.setText(self.tr('Delete row'))
8383
self.buttonBox.addButton(self.addRowButton,
8484
QtGui.QDialogButtonBox.ActionRole)
8585
self.buttonBox.addButton(self.deleteRowButton,
@@ -151,7 +151,7 @@ def setTableContent(self):
151151

152152
if self.alg.getVisibleOutputsCount():
153153
self.table.setHorizontalHeaderItem(i,
154-
QtGui.QTableWidgetItem('Load in QGIS'))
154+
QtGui.QTableWidgetItem(self.tr('Load in QGIS')))
155155

156156
for i in range(3):
157157
self.addRow()
@@ -168,9 +168,8 @@ def accept(self):
168168
continue
169169
widget = self.table.cellWidget(row, col)
170170
if not self.setParameterValueFromWidget(param, widget, alg):
171-
self.progressLabel.setText('<b>Missing parameter value: '
172-
+ param.description + ' (row ' + str(row + 1)
173-
+ ')</b>')
171+
self.progressLabel.setText(
172+
self.tr('<b>Missing parameter value: %s (row %d)</b>') % (param.description, row + 1))
174173
self.algs = None
175174
return
176175
col += 1
@@ -184,9 +183,7 @@ def accept(self):
184183
col += 1
185184
else:
186185
self.progressLabel.setText(
187-
'<b>Wrong or missing parameter value: '
188-
+ out.description + ' (row ' + str(row + 1)
189-
+ ')</b>')
186+
self.tr('<b>Wrong or missing parameter value: %s (row %d)</b>') % (out.description, row + 1))
190187
self.algs = None
191188
return
192189
self.algs.append(alg)
@@ -206,13 +203,12 @@ def accept(self):
206203
except:
207204
pass
208205
for (i, alg) in enumerate(self.algs):
209-
self.setBaseText('Processing algorithm ' + str(i + 1) + '/'
210-
+ str(len(self.algs)) + '...')
211-
self.setInfo('<b>Algorithm %s starting...</b>' % alg.name)
206+
self.setBaseText(self.tr('Processing algorithm %d/%d...') %(i + 1, len(self.algs)))
207+
self.setInfo(self.tr('<b>Algorithm %s starting...</b>' % alg.name))
212208
if runalg(alg, self) and not self.canceled:
213209
if self.load[i]:
214210
handleAlgorithmResults(alg, self, False)
215-
self.setInfo('Algorithm %s correctly executed...' % alg.name)
211+
self.setInfo(self.tr('Algorithm %s correctly executed...') % alg.name)
216212
else:
217213
QApplication.restoreOverrideCursor()
218214
return
@@ -260,8 +256,8 @@ def finishAll(self):
260256
self.createSummaryTable()
261257
QApplication.restoreOverrideCursor()
262258
self.table.setEnabled(True)
263-
QMessageBox.information(self, 'Batch processing',
264-
'Batch processing successfully completed!')
259+
QMessageBox.information(self, self.tr('Batch processing'),
260+
self.tr('Batch processing successfully completed!'))
265261

266262
def setParameterValueFromWidget(self, param, widget, alg=None):
267263
if isinstance(param, (ParameterRaster, ParameterVector,
@@ -291,8 +287,8 @@ def getWidgetFromParameter(self, param, row, col):
291287
item = BatchInputSelectionPanel(param, row, col, self)
292288
elif isinstance(param, ParameterBoolean):
293289
item = QtGui.QComboBox()
294-
item.addItem('Yes')
295-
item.addItem('No')
290+
item.addItem(self.tr('Yes'))
291+
item.addItem(self.tr('No'))
296292
if param.default:
297293
item.setCurrentIndex(0)
298294
else:
@@ -341,17 +337,17 @@ def addRow(self):
341337

342338
if self.alg.getVisibleOutputsCount():
343339
item = QtGui.QComboBox()
344-
item.addItem('Yes')
345-
item.addItem('No')
340+
item.addItem(self.tr('Yes'))
341+
item.addItem(self.tr('No'))
346342
item.setCurrentIndex(0)
347343
self.table.setCellWidget(self.table.rowCount() - 1, i, item)
348344

349345
def showAdvancedParametersClicked(self):
350346
self.showAdvanced = not self.showAdvanced
351347
if self.showAdvanced:
352-
self.advancedButton.setText('Hide advanced parameters')
348+
self.advancedButton.setText(self.tr('Hide advanced parameters'))
353349
else:
354-
self.advancedButton.setText('Show advanced parameters')
350+
self.advancedButton.setText(self.tr('Show advanced parameters'))
355351
i = 0
356352
for param in self.alg.parameters:
357353
if param.isAdvanced:

python/plugins/processing/gui/ConfigDialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def fillTree(self):
7474
settings = ProcessingConfig.getSettings()
7575

7676
rootItem = self.model.invisibleRootItem()
77-
priorityKeys = ['General', 'Models', 'Scripts']
77+
priorityKeys = [self.tr('General'), self.tr('Models'), self.tr('Scripts')]
7878
for group in priorityKeys:
7979
groupItem = QStandardItem(group)
8080
icon = ProcessingConfig.getGroupIcon(group)
@@ -141,7 +141,7 @@ def accept(self):
141141
setting.value = value
142142
except ValueError:
143143
QMessageBox.critical(self, self.tr('Wrong value'),
144-
self.tr('Wrong parameter value:\n%1').arg(value))
144+
self.tr('Wrong parameter value:\n%1') % value)
145145
return
146146
else:
147147
setting.value = unicode(self.items[setting].text())

python/plugins/processing/gui/CouldNotLoadResultsDialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def __init__(self, wrongLayers, alg):
4242

4343
def setupUi(self):
4444
self.resize(600, 350)
45-
self.setWindowTitle('Problem loading output layers')
45+
self.setWindowTitle(self.tr('Problem loading output layers'))
4646
layout = QVBoxLayout()
4747
browser = QtGui.QTextBrowser()
4848
browser.setOpenLinks(False)
4949
browser.anchorClicked.connect(self.linkClicked)
5050
html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
5151
browser.setHtml(html)
5252
button = QPushButton()
53-
button.setText('Close')
53+
button.setText(self.tr('Close'))
5454
button.clicked.connect(self.closeButtonPressed)
5555
buttonBox = QtGui.QDialogButtonBox()
5656
buttonBox.setOrientation(QtCore.Qt.Horizontal)

python/plugins/processing/gui/CreateNewScriptAction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CreateNewScriptAction(ToolboxAction):
3737

3838
def __init__(self, actionName, scriptType):
3939
self.name = actionName
40-
self.group = 'Tools'
40+
self.group = self.tr('Tools', 'CreateNewScriptAction')
4141
self.scriptType = scriptType
4242

4343
def getIcon(self):

0 commit comments

Comments
 (0)