Skip to content

Commit

Permalink
[processing] make bunch of strings translatable (sorry translators)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 4, 2014
1 parent f935316 commit bd13693
Show file tree
Hide file tree
Showing 48 changed files with 331 additions and 317 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def getPostProcessingErrorMessage(self, wrongLayers):
for layer in wrongLayers:
html += self.tr('<li>%s: <font size=3 face="Courier New" '
'color="#ff0000">%s</font></li>\n') % \
(layer.description, layer.value)
(layer.description, layer.value)
html += self.tr('</ul><p>The above files could not be opened, which '
'probably indicates that they were not correctly '
'produced by the executed algorithm</p>'
Expand All @@ -532,4 +532,4 @@ def getPostProcessingErrorMessage(self, wrongLayers):
def tr(self, string, context=''):
if context == '':
context = 'GeoAlgorithm'
return QtCore.QCoreApplication.translate(context, string)
return QCoreApplication.translate(context, string)
10 changes: 5 additions & 5 deletions python/plugins/processing/core/Processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def addProvider(provider, updateList=False):
Processing.updateAlgsList()
except:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not load provider: %s\n%s')
% (provider.getDescription(), unicode(sys.exc_info()[1])))
self.tr('Could not load provider: %s\n%s')
% (provider.getDescription(), unicode(sys.exc_info()[1])))
Processing.removeProvider(provider)

@staticmethod
Expand Down Expand Up @@ -284,16 +284,16 @@ def runAlgorithm(algOrName, onFinish, *args):
print 'Error: Wrong parameter value %s for parameter %s.' \
% (value, name)
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr("Error in %s. Wrong parameter value %s for parameter %s.") \
self.tr('Error in %s. Wrong parameter value %s for parameter %s.') \
% (alg.name, value, name))
return
# fill any missing parameters with default values if allowed
for param in alg.parameters:
if param.name not in setParams:
if not param.setValue(None):
print ("Error: Missing parameter value for parameter %s." % (param.name))
print ('Error: Missing parameter value for parameter %s.' % (param.name))
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr("Error in %s. Missing parameter value for parameter %s.") \
self.tr('Error in %s. Missing parameter value for parameter %s.') \
% (alg.name, param.name))
return
else:
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/core/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def getFileFilter(self):
else:
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)):
exts[i] = self.tr('%s files(*.%s', 'ParameterMultipleInput') % (exts[i].upper(), exts[i].lower())
exts[i] = self.tr('%s files(*.%s)', 'ParameterMultipleInput') % (exts[i].upper(), exts[i].lower())
return ';;'.join(exts)


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


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


Expand Down Expand Up @@ -721,5 +721,5 @@ def getSafeExportedLayer(self):
def getFileFilter(self):
exts = dataobjects.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)):
exts[i] = self.tr('%s files(*.%s', 'ParameterVector') % (exts[i].upper(), exts[i].lower())
exts[i] = self.tr('%s files(*.%s)', 'ParameterVector') % (exts[i].upper(), exts[i].lower())
return ';;'.join(exts)
47 changes: 26 additions & 21 deletions python/plugins/processing/gui/AlgorithmExecutionDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, alg, mainWidget):
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
self.runButton = QPushButton()
self.runButton.setText('Run')
self.runButton.setText(self.tr('Run'))
self.buttonBox.addButton(self.runButton, QDialogButtonBox.ActionRole)
self.runButton.clicked.connect(self.accept)
self.setWindowTitle(self.alg.name)
Expand All @@ -78,11 +78,11 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.setMargin(9)
self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.mainWidget, 'Parameters')
self.tabWidget.addTab(self.mainWidget, self.tr('Parameters'))
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
self.tabWidget.addTab(self.logText, 'Log')
self.tabWidget.addTab(self.logText, self.tr('Log'))
self.webView = QWebView()
html = None
url = None
Expand All @@ -93,15 +93,16 @@ def __init__(self, alg, mainWidget):
else:
url = QUrl(help)
else:
html = '<h2>Sorry, no help is available for this \
algorithm.</h2>'
html = self.tr('<h2>Sorry, no help is available for this '
'algorithm.</h2>')
try:
if html:
self.webView.setHtml(html)
elif url:
self.webView.load(url)
except:
self.webView.setHtml('<h2>Could not open help file :-( </h2>')
self.webView.setHtml(
self.tr('<h2>Could not open help file :-( </h2>'))
self.tabWidget.addTab(self.webView, 'Help')
self.verticalLayout.addWidget(self.progressLabel)
self.verticalLayout.addWidget(self.progress)
Expand Down Expand Up @@ -195,17 +196,18 @@ def accept(self):
try:
self.setParamValues()
if checkCRS and not self.alg.checkInputCRS():
reply = QMessageBox.question(self, "Unmatching CRS's",
'Layers do not all use the same CRS.\n'
+ 'This can cause unexpected results.\n'
+ 'Do you want to continue?',
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
self.tr('Layers do not all use the same CRS. This can '
'cause unexpected results.\nDo you want to'
'continue?'),
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
if reply == QMessageBox.No:
return
msg = self.alg.checkParameterValuesBeforeExecuting()
if msg:
QMessageBox.warning(self, 'Unable to execute algorithm', msg)
QMessageBox.warning(
self, self.tr('Unable to execute algorithm'), msg)
return
self.runButton.setEnabled(False)
self.buttonBox.button(
Expand All @@ -221,10 +223,11 @@ def accept(self):

self.tabWidget.setCurrentIndex(1) # Log tab
self.progress.setMaximum(0)
self.progressLabel.setText('Processing algorithm...')
self.progressLabel.setText(self.tr('Processing algorithm...'))
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name)
self.setInfo(
self.tr('<b>Algorithm %s starting...</b>') % self.alg.name)
# make sure the log tab is visible before executing the algorithm
try:
self.repaint()
Expand Down Expand Up @@ -254,12 +257,13 @@ def accept(self):
palette = ex.widget.palette()
palette.setColor(QPalette.Base, QColor(255, 255, 0))
ex.widget.setPalette(palette)
self.progressLabel.setText('<b>Missing parameter value: '
+ ex.parameter.description + '</b>')
self.progressLabel.setText(
self.tr('<b>Missing parameter value: %s</b>' % ex.parameter.description))
return
except:
QMessageBox.critical(self, 'Unable to execute algorithm',
'Wrong or missing parameter values')
QMessageBox.critical(self,
self.tr('Unable to execute algorithm'),
self.tr('Wrong or missing parameter values'))

def finish(self):
keepOpen = ProcessingConfig.getSetting(
Expand All @@ -274,8 +278,9 @@ def finish(self):
else:
self.resetGUI()
if self.alg.getHTMLOutputsCount() > 0:
self.setInfo('HTML output has been generated by this '
+ 'algorithm.\nOpen the results dialog to check it.')
self.setInfo(
self.tr('HTML output has been generated by this algorithm.'
'\nOpen the results dialog to check it.'))

def error(self, msg):
QApplication.restoreOverrideCursor()
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/gui/BatchInputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def showPopupMenu(self):
popupmenu = QtGui.QMenu()
if not (isinstance(self.param, ParameterMultipleInput)
and self.param.datatype == ParameterMultipleInput.TYPE_FILE):
selectLayerAction = QtGui.QAction('Select from open layers',
selectLayerAction = QtGui.QAction(self.tr('Select from open layers'),
self.pushButton)
selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
popupmenu.addAction(selectLayerAction)
selectFileAction = QtGui.QAction('Select from filesystem',
selectFileAction = QtGui.QAction(self.tr('Select from filesystem'),
self.pushButton)
selectFileAction.triggered.connect(self.showFileSelectionDialog)
popupmenu.addAction(selectFileAction)
Expand Down Expand Up @@ -114,8 +114,8 @@ def showFileSelectionDialog(self):
else:
path = ''

ret = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', path,
'All files(*.*);;' + self.param.getFileFilter())
ret = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'), path,
self.tr('All files(*.*);;') + self.param.getFileFilter())
if ret:
files = list(ret)
if len(files) == 1:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/BatchOutputSelectionPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, output, alg, row, col, batchDialog):

def showSelectionDialog(self):
filefilter = self.output.getFileFilter(self.alg)
filename = QtGui.QFileDialog.getSaveFileName(self, 'Save file', '',
filename = QtGui.QFileDialog.getSaveFileName(self, self.tr('Save file'), '',
filefilter)
if filename:
filename = unicode(filename)
Expand Down
42 changes: 19 additions & 23 deletions python/plugins/processing/gui/BatchProcessingDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ def __init__(self, alg):
AlgorithmExecutionDialog.__init__(self, alg, self.table)
self.setWindowModality(1)
self.resize(800, 500)
self.setWindowTitle('Batch Processing - ' + self.alg.name)
self.setWindowTitle(self.tr('Batch Processing - %s') % self.alg.name)
for param in self.alg.parameters:
if param.isAdvanced:
self.advancedButton = QtGui.QPushButton()
self.advancedButton.setText('Show advanced parameters')
self.advancedButton.setText(self.tr('Show advanced parameters'))
self.advancedButton.setMaximumWidth(150)
self.buttonBox.addButton(self.advancedButton,
QtGui.QDialogButtonBox.ActionRole)
self.advancedButton.clicked.connect(
self.showAdvancedParametersClicked)
break
self.addRowButton = QtGui.QPushButton()
self.addRowButton.setText('Add row')
self.addRowButton.setText(self.tr('Add row'))
self.buttonBox.addButton(self.addRowButton,
QtGui.QDialogButtonBox.ActionRole)
self.deleteRowButton = QtGui.QPushButton()
self.deleteRowButton.setText('Delete row')
self.deleteRowButton.setText(self.tr('Delete row'))
self.buttonBox.addButton(self.addRowButton,
QtGui.QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.deleteRowButton,
Expand Down Expand Up @@ -151,7 +151,7 @@ def setTableContent(self):

if self.alg.getVisibleOutputsCount():
self.table.setHorizontalHeaderItem(i,
QtGui.QTableWidgetItem('Load in QGIS'))
QtGui.QTableWidgetItem(self.tr('Load in QGIS')))

for i in range(3):
self.addRow()
Expand All @@ -168,9 +168,8 @@ def accept(self):
continue
widget = self.table.cellWidget(row, col)
if not self.setParameterValueFromWidget(param, widget, alg):
self.progressLabel.setText('<b>Missing parameter value: '
+ param.description + ' (row ' + str(row + 1)
+ ')</b>')
self.progressLabel.setText(
self.tr('<b>Missing parameter value: %s (row %d)</b>') % (param.description, row + 1))
self.algs = None
return
col += 1
Expand All @@ -184,9 +183,7 @@ def accept(self):
col += 1
else:
self.progressLabel.setText(
'<b>Wrong or missing parameter value: '
+ out.description + ' (row ' + str(row + 1)
+ ')</b>')
self.tr('<b>Wrong or missing parameter value: %s (row %d)</b>') % (out.description, row + 1))
self.algs = None
return
self.algs.append(alg)
Expand All @@ -206,13 +203,12 @@ def accept(self):
except:
pass
for (i, alg) in enumerate(self.algs):
self.setBaseText('Processing algorithm ' + str(i + 1) + '/'
+ str(len(self.algs)) + '...')
self.setInfo('<b>Algorithm %s starting...</b>' % alg.name)
self.setBaseText(self.tr('Processing algorithm %d/%d...') %(i + 1, len(self.algs)))
self.setInfo(self.tr('<b>Algorithm %s starting...</b>' % alg.name))
if runalg(alg, self) and not self.canceled:
if self.load[i]:
handleAlgorithmResults(alg, self, False)
self.setInfo('Algorithm %s correctly executed...' % alg.name)
self.setInfo(self.tr('Algorithm %s correctly executed...') % alg.name)
else:
QApplication.restoreOverrideCursor()
return
Expand Down Expand Up @@ -260,8 +256,8 @@ def finishAll(self):
self.createSummaryTable()
QApplication.restoreOverrideCursor()
self.table.setEnabled(True)
QMessageBox.information(self, 'Batch processing',
'Batch processing successfully completed!')
QMessageBox.information(self, self.tr('Batch processing'),
self.tr('Batch processing successfully completed!'))

def setParameterValueFromWidget(self, param, widget, alg=None):
if isinstance(param, (ParameterRaster, ParameterVector,
Expand Down Expand Up @@ -291,8 +287,8 @@ def getWidgetFromParameter(self, param, row, col):
item = BatchInputSelectionPanel(param, row, col, self)
elif isinstance(param, ParameterBoolean):
item = QtGui.QComboBox()
item.addItem('Yes')
item.addItem('No')
item.addItem(self.tr('Yes'))
item.addItem(self.tr('No'))
if param.default:
item.setCurrentIndex(0)
else:
Expand Down Expand Up @@ -341,17 +337,17 @@ def addRow(self):

if self.alg.getVisibleOutputsCount():
item = QtGui.QComboBox()
item.addItem('Yes')
item.addItem('No')
item.addItem(self.tr('Yes'))
item.addItem(self.tr('No'))
item.setCurrentIndex(0)
self.table.setCellWidget(self.table.rowCount() - 1, i, item)

def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced
if self.showAdvanced:
self.advancedButton.setText('Hide advanced parameters')
self.advancedButton.setText(self.tr('Hide advanced parameters'))
else:
self.advancedButton.setText('Show advanced parameters')
self.advancedButton.setText(self.tr('Show advanced parameters'))
i = 0
for param in self.alg.parameters:
if param.isAdvanced:
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/ConfigDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def fillTree(self):
settings = ProcessingConfig.getSettings()

rootItem = self.model.invisibleRootItem()
priorityKeys = ['General', 'Models', 'Scripts']
priorityKeys = [self.tr('General'), self.tr('Models'), self.tr('Scripts')]
for group in priorityKeys:
groupItem = QStandardItem(group)
icon = ProcessingConfig.getGroupIcon(group)
Expand Down Expand Up @@ -141,7 +141,7 @@ def accept(self):
setting.value = value
except ValueError:
QMessageBox.critical(self, self.tr('Wrong value'),
self.tr('Wrong parameter value:\n%1').arg(value))
self.tr('Wrong parameter value:\n%1') % value)
return
else:
setting.value = unicode(self.items[setting].text())
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/CouldNotLoadResultsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def __init__(self, wrongLayers, alg):

def setupUi(self):
self.resize(600, 350)
self.setWindowTitle('Problem loading output layers')
self.setWindowTitle(self.tr('Problem loading output layers'))
layout = QVBoxLayout()
browser = QtGui.QTextBrowser()
browser.setOpenLinks(False)
browser.anchorClicked.connect(self.linkClicked)
html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
browser.setHtml(html)
button = QPushButton()
button.setText('Close')
button.setText(self.tr('Close'))
button.clicked.connect(self.closeButtonPressed)
buttonBox = QtGui.QDialogButtonBox()
buttonBox.setOrientation(QtCore.Qt.Horizontal)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/CreateNewScriptAction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CreateNewScriptAction(ToolboxAction):

def __init__(self, actionName, scriptType):
self.name = actionName
self.group = 'Tools'
self.group = self.tr('Tools', 'CreateNewScriptAction')
self.scriptType = scriptType

def getIcon(self):
Expand Down
Loading

0 comments on commit bd13693

Please sign in to comment.