[processing] make bunch of strings translatable (sorry translators)

This commit is contained in:
Alexander Bruy 2014-10-03 21:56:24 +03:00
parent f935316882
commit bd13693ae3
48 changed files with 331 additions and 317 deletions

View File

@ -521,7 +521,7 @@ class GeoAlgorithm:
for layer in wrongLayers: for layer in wrongLayers:
html += self.tr('<li>%s: <font size=3 face="Courier New" ' html += self.tr('<li>%s: <font size=3 face="Courier New" '
'color="#ff0000">%s</font></li>\n') % \ '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 ' html += self.tr('</ul><p>The above files could not be opened, which '
'probably indicates that they were not correctly ' 'probably indicates that they were not correctly '
'produced by the executed algorithm</p>' 'produced by the executed algorithm</p>'
@ -532,4 +532,4 @@ class GeoAlgorithm:
def tr(self, string, context=''): def tr(self, string, context=''):
if context == '': if context == '':
context = 'GeoAlgorithm' context = 'GeoAlgorithm'
return QtCore.QCoreApplication.translate(context, string) return QCoreApplication.translate(context, string)

View File

@ -95,8 +95,8 @@ class Processing:
Processing.updateAlgsList() Processing.updateAlgsList()
except: except:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
self.tr('Could not load provider: %s\n%s') self.tr('Could not load provider: %s\n%s')
% (provider.getDescription(), unicode(sys.exc_info()[1]))) % (provider.getDescription(), unicode(sys.exc_info()[1])))
Processing.removeProvider(provider) Processing.removeProvider(provider)
@staticmethod @staticmethod
@ -284,16 +284,16 @@ class Processing:
print 'Error: Wrong parameter value %s for parameter %s.' \ print 'Error: Wrong parameter value %s for parameter %s.' \
% (value, name) % (value, name)
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, 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)) % (alg.name, value, name))
return return
# fill any missing parameters with default values if allowed # fill any missing parameters with default values if allowed
for param in alg.parameters: for param in alg.parameters:
if param.name not in setParams: if param.name not in setParams:
if not param.setValue(None): 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, 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)) % (alg.name, param.name))
return return
else: else:

View File

@ -364,7 +364,7 @@ class ParameterMultipleInput(ParameterDataObject):
else: else:
exts = dataobjects.getSupportedOutputVectorLayerExtensions() exts = dataobjects.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)): 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) return ';;'.join(exts)
@ -495,7 +495,7 @@ class ParameterRaster(ParameterDataObject):
def getFileFilter(self): def getFileFilter(self):
exts = dataobjects.getSupportedOutputRasterLayerExtensions() exts = dataobjects.getSupportedOutputRasterLayerExtensions()
for i in range(len(exts)): 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) return ';;'.join(exts)
@ -612,7 +612,7 @@ class ParameterTable(ParameterDataObject):
def getFileFilter(self): def getFileFilter(self):
exts = ['csv', 'dbf'] exts = ['csv', 'dbf']
for i in range(len(exts)): 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) return ';;'.join(exts)
@ -721,5 +721,5 @@ class ParameterVector(ParameterDataObject):
def getFileFilter(self): def getFileFilter(self):
exts = dataobjects.getSupportedOutputVectorLayerExtensions() exts = dataobjects.getSupportedOutputVectorLayerExtensions()
for i in range(len(exts)): 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) return ';;'.join(exts)

View File

@ -64,7 +64,7 @@ class AlgorithmExecutionDialog(QDialog):
self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Close) self.buttonBox.setStandardButtons(QDialogButtonBox.Close)
self.runButton = QPushButton() self.runButton = QPushButton()
self.runButton.setText('Run') self.runButton.setText(self.tr('Run'))
self.buttonBox.addButton(self.runButton, QDialogButtonBox.ActionRole) self.buttonBox.addButton(self.runButton, QDialogButtonBox.ActionRole)
self.runButton.clicked.connect(self.accept) self.runButton.clicked.connect(self.accept)
self.setWindowTitle(self.alg.name) self.setWindowTitle(self.alg.name)
@ -78,11 +78,11 @@ class AlgorithmExecutionDialog(QDialog):
self.verticalLayout.setMargin(9) self.verticalLayout.setMargin(9)
self.tabWidget = QTabWidget() self.tabWidget = QTabWidget()
self.tabWidget.setMinimumWidth(300) self.tabWidget.setMinimumWidth(300)
self.tabWidget.addTab(self.mainWidget, 'Parameters') self.tabWidget.addTab(self.mainWidget, self.tr('Parameters'))
self.verticalLayout.addWidget(self.tabWidget) self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit() self.logText = QTextEdit()
self.logText.readOnly = True self.logText.readOnly = True
self.tabWidget.addTab(self.logText, 'Log') self.tabWidget.addTab(self.logText, self.tr('Log'))
self.webView = QWebView() self.webView = QWebView()
html = None html = None
url = None url = None
@ -93,15 +93,16 @@ class AlgorithmExecutionDialog(QDialog):
else: else:
url = QUrl(help) url = QUrl(help)
else: else:
html = '<h2>Sorry, no help is available for this \ html = self.tr('<h2>Sorry, no help is available for this '
algorithm.</h2>' 'algorithm.</h2>')
try: try:
if html: if html:
self.webView.setHtml(html) self.webView.setHtml(html)
elif url: elif url:
self.webView.load(url) self.webView.load(url)
except: 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.tabWidget.addTab(self.webView, 'Help')
self.verticalLayout.addWidget(self.progressLabel) self.verticalLayout.addWidget(self.progressLabel)
self.verticalLayout.addWidget(self.progress) self.verticalLayout.addWidget(self.progress)
@ -195,17 +196,18 @@ class AlgorithmExecutionDialog(QDialog):
try: try:
self.setParamValues() self.setParamValues()
if checkCRS and not self.alg.checkInputCRS(): if checkCRS and not self.alg.checkInputCRS():
reply = QMessageBox.question(self, "Unmatching CRS's", reply = QMessageBox.question(self, self.tr("Unmatching CRS's"),
'Layers do not all use the same CRS.\n' self.tr('Layers do not all use the same CRS. This can '
+ 'This can cause unexpected results.\n' 'cause unexpected results.\nDo you want to'
+ 'Do you want to continue?', 'continue?'),
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) QMessageBox.No)
if reply == QMessageBox.No: if reply == QMessageBox.No:
return return
msg = self.alg.checkParameterValuesBeforeExecuting() msg = self.alg.checkParameterValuesBeforeExecuting()
if msg: if msg:
QMessageBox.warning(self, 'Unable to execute algorithm', msg) QMessageBox.warning(
self, self.tr('Unable to execute algorithm'), msg)
return return
self.runButton.setEnabled(False) self.runButton.setEnabled(False)
self.buttonBox.button( self.buttonBox.button(
@ -221,10 +223,11 @@ class AlgorithmExecutionDialog(QDialog):
self.tabWidget.setCurrentIndex(1) # Log tab self.tabWidget.setCurrentIndex(1) # Log tab
self.progress.setMaximum(0) self.progress.setMaximum(0)
self.progressLabel.setText('Processing algorithm...') self.progressLabel.setText(self.tr('Processing algorithm...'))
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) 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 # make sure the log tab is visible before executing the algorithm
try: try:
self.repaint() self.repaint()
@ -254,12 +257,13 @@ class AlgorithmExecutionDialog(QDialog):
palette = ex.widget.palette() palette = ex.widget.palette()
palette.setColor(QPalette.Base, QColor(255, 255, 0)) palette.setColor(QPalette.Base, QColor(255, 255, 0))
ex.widget.setPalette(palette) ex.widget.setPalette(palette)
self.progressLabel.setText('<b>Missing parameter value: ' self.progressLabel.setText(
+ ex.parameter.description + '</b>') self.tr('<b>Missing parameter value: %s</b>' % ex.parameter.description))
return return
except: except:
QMessageBox.critical(self, 'Unable to execute algorithm', QMessageBox.critical(self,
'Wrong or missing parameter values') self.tr('Unable to execute algorithm'),
self.tr('Wrong or missing parameter values'))
def finish(self): def finish(self):
keepOpen = ProcessingConfig.getSetting( keepOpen = ProcessingConfig.getSetting(
@ -274,8 +278,9 @@ class AlgorithmExecutionDialog(QDialog):
else: else:
self.resetGUI() self.resetGUI()
if self.alg.getHTMLOutputsCount() > 0: if self.alg.getHTMLOutputsCount() > 0:
self.setInfo('HTML output has been generated by this ' self.setInfo(
+ 'algorithm.\nOpen the results dialog to check it.') self.tr('HTML output has been generated by this algorithm.'
'\nOpen the results dialog to check it.'))
def error(self, msg): def error(self, msg):
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()

View File

@ -62,11 +62,11 @@ class BatchInputSelectionPanel(QtGui.QWidget):
popupmenu = QtGui.QMenu() popupmenu = QtGui.QMenu()
if not (isinstance(self.param, ParameterMultipleInput) if not (isinstance(self.param, ParameterMultipleInput)
and self.param.datatype == ParameterMultipleInput.TYPE_FILE): 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) self.pushButton)
selectLayerAction.triggered.connect(self.showLayerSelectionDialog) selectLayerAction.triggered.connect(self.showLayerSelectionDialog)
popupmenu.addAction(selectLayerAction) popupmenu.addAction(selectLayerAction)
selectFileAction = QtGui.QAction('Select from filesystem', selectFileAction = QtGui.QAction(self.tr('Select from filesystem'),
self.pushButton) self.pushButton)
selectFileAction.triggered.connect(self.showFileSelectionDialog) selectFileAction.triggered.connect(self.showFileSelectionDialog)
popupmenu.addAction(selectFileAction) popupmenu.addAction(selectFileAction)
@ -114,8 +114,8 @@ class BatchInputSelectionPanel(QtGui.QWidget):
else: else:
path = '' path = ''
ret = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', path, ret = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'), path,
'All files(*.*);;' + self.param.getFileFilter()) self.tr('All files(*.*);;') + self.param.getFileFilter())
if ret: if ret:
files = list(ret) files = list(ret)
if len(files) == 1: if len(files) == 1:

View File

@ -63,7 +63,7 @@ class BatchOutputSelectionPanel(QtGui.QWidget):
def showSelectionDialog(self): def showSelectionDialog(self):
filefilter = self.output.getFileFilter(self.alg) filefilter = self.output.getFileFilter(self.alg)
filename = QtGui.QFileDialog.getSaveFileName(self, 'Save file', '', filename = QtGui.QFileDialog.getSaveFileName(self, self.tr('Save file'), '',
filefilter) filefilter)
if filename: if filename:
filename = unicode(filename) filename = unicode(filename)

View File

@ -63,11 +63,11 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
AlgorithmExecutionDialog.__init__(self, alg, self.table) AlgorithmExecutionDialog.__init__(self, alg, self.table)
self.setWindowModality(1) self.setWindowModality(1)
self.resize(800, 500) 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: for param in self.alg.parameters:
if param.isAdvanced: if param.isAdvanced:
self.advancedButton = QtGui.QPushButton() self.advancedButton = QtGui.QPushButton()
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
self.advancedButton.setMaximumWidth(150) self.advancedButton.setMaximumWidth(150)
self.buttonBox.addButton(self.advancedButton, self.buttonBox.addButton(self.advancedButton,
QtGui.QDialogButtonBox.ActionRole) QtGui.QDialogButtonBox.ActionRole)
@ -75,11 +75,11 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
self.showAdvancedParametersClicked) self.showAdvancedParametersClicked)
break break
self.addRowButton = QtGui.QPushButton() self.addRowButton = QtGui.QPushButton()
self.addRowButton.setText('Add row') self.addRowButton.setText(self.tr('Add row'))
self.buttonBox.addButton(self.addRowButton, self.buttonBox.addButton(self.addRowButton,
QtGui.QDialogButtonBox.ActionRole) QtGui.QDialogButtonBox.ActionRole)
self.deleteRowButton = QtGui.QPushButton() self.deleteRowButton = QtGui.QPushButton()
self.deleteRowButton.setText('Delete row') self.deleteRowButton.setText(self.tr('Delete row'))
self.buttonBox.addButton(self.addRowButton, self.buttonBox.addButton(self.addRowButton,
QtGui.QDialogButtonBox.ActionRole) QtGui.QDialogButtonBox.ActionRole)
self.buttonBox.addButton(self.deleteRowButton, self.buttonBox.addButton(self.deleteRowButton,
@ -151,7 +151,7 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
if self.alg.getVisibleOutputsCount(): if self.alg.getVisibleOutputsCount():
self.table.setHorizontalHeaderItem(i, self.table.setHorizontalHeaderItem(i,
QtGui.QTableWidgetItem('Load in QGIS')) QtGui.QTableWidgetItem(self.tr('Load in QGIS')))
for i in range(3): for i in range(3):
self.addRow() self.addRow()
@ -168,9 +168,8 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
continue continue
widget = self.table.cellWidget(row, col) widget = self.table.cellWidget(row, col)
if not self.setParameterValueFromWidget(param, widget, alg): if not self.setParameterValueFromWidget(param, widget, alg):
self.progressLabel.setText('<b>Missing parameter value: ' self.progressLabel.setText(
+ param.description + ' (row ' + str(row + 1) self.tr('<b>Missing parameter value: %s (row %d)</b>') % (param.description, row + 1))
+ ')</b>')
self.algs = None self.algs = None
return return
col += 1 col += 1
@ -184,9 +183,7 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
col += 1 col += 1
else: else:
self.progressLabel.setText( self.progressLabel.setText(
'<b>Wrong or missing parameter value: ' self.tr('<b>Wrong or missing parameter value: %s (row %d)</b>') % (out.description, row + 1))
+ out.description + ' (row ' + str(row + 1)
+ ')</b>')
self.algs = None self.algs = None
return return
self.algs.append(alg) self.algs.append(alg)
@ -206,13 +203,12 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
except: except:
pass pass
for (i, alg) in enumerate(self.algs): for (i, alg) in enumerate(self.algs):
self.setBaseText('Processing algorithm ' + str(i + 1) + '/' self.setBaseText(self.tr('Processing algorithm %d/%d...') %(i + 1, len(self.algs)))
+ str(len(self.algs)) + '...') self.setInfo(self.tr('<b>Algorithm %s starting...</b>' % alg.name))
self.setInfo('<b>Algorithm %s starting...</b>' % alg.name)
if runalg(alg, self) and not self.canceled: if runalg(alg, self) and not self.canceled:
if self.load[i]: if self.load[i]:
handleAlgorithmResults(alg, self, False) handleAlgorithmResults(alg, self, False)
self.setInfo('Algorithm %s correctly executed...' % alg.name) self.setInfo(self.tr('Algorithm %s correctly executed...') % alg.name)
else: else:
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
return return
@ -260,8 +256,8 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
self.createSummaryTable() self.createSummaryTable()
QApplication.restoreOverrideCursor() QApplication.restoreOverrideCursor()
self.table.setEnabled(True) self.table.setEnabled(True)
QMessageBox.information(self, 'Batch processing', QMessageBox.information(self, self.tr('Batch processing'),
'Batch processing successfully completed!') self.tr('Batch processing successfully completed!'))
def setParameterValueFromWidget(self, param, widget, alg=None): def setParameterValueFromWidget(self, param, widget, alg=None):
if isinstance(param, (ParameterRaster, ParameterVector, if isinstance(param, (ParameterRaster, ParameterVector,
@ -291,8 +287,8 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
item = BatchInputSelectionPanel(param, row, col, self) item = BatchInputSelectionPanel(param, row, col, self)
elif isinstance(param, ParameterBoolean): elif isinstance(param, ParameterBoolean):
item = QtGui.QComboBox() item = QtGui.QComboBox()
item.addItem('Yes') item.addItem(self.tr('Yes'))
item.addItem('No') item.addItem(self.tr('No'))
if param.default: if param.default:
item.setCurrentIndex(0) item.setCurrentIndex(0)
else: else:
@ -341,17 +337,17 @@ class BatchProcessingDialog(AlgorithmExecutionDialog):
if self.alg.getVisibleOutputsCount(): if self.alg.getVisibleOutputsCount():
item = QtGui.QComboBox() item = QtGui.QComboBox()
item.addItem('Yes') item.addItem(self.tr('Yes'))
item.addItem('No') item.addItem(self.tr('No'))
item.setCurrentIndex(0) item.setCurrentIndex(0)
self.table.setCellWidget(self.table.rowCount() - 1, i, item) self.table.setCellWidget(self.table.rowCount() - 1, i, item)
def showAdvancedParametersClicked(self): def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced self.showAdvanced = not self.showAdvanced
if self.showAdvanced: if self.showAdvanced:
self.advancedButton.setText('Hide advanced parameters') self.advancedButton.setText(self.tr('Hide advanced parameters'))
else: else:
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
i = 0 i = 0
for param in self.alg.parameters: for param in self.alg.parameters:
if param.isAdvanced: if param.isAdvanced:

View File

@ -74,7 +74,7 @@ class ConfigDialog(QDialog, Ui_DlgConfig):
settings = ProcessingConfig.getSettings() settings = ProcessingConfig.getSettings()
rootItem = self.model.invisibleRootItem() rootItem = self.model.invisibleRootItem()
priorityKeys = ['General', 'Models', 'Scripts'] priorityKeys = [self.tr('General'), self.tr('Models'), self.tr('Scripts')]
for group in priorityKeys: for group in priorityKeys:
groupItem = QStandardItem(group) groupItem = QStandardItem(group)
icon = ProcessingConfig.getGroupIcon(group) icon = ProcessingConfig.getGroupIcon(group)
@ -141,7 +141,7 @@ class ConfigDialog(QDialog, Ui_DlgConfig):
setting.value = value setting.value = value
except ValueError: except ValueError:
QMessageBox.critical(self, self.tr('Wrong value'), 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 return
else: else:
setting.value = unicode(self.items[setting].text()) setting.value = unicode(self.items[setting].text())

View File

@ -42,7 +42,7 @@ class CouldNotLoadResultsDialog(QtGui.QDialog):
def setupUi(self): def setupUi(self):
self.resize(600, 350) self.resize(600, 350)
self.setWindowTitle('Problem loading output layers') self.setWindowTitle(self.tr('Problem loading output layers'))
layout = QVBoxLayout() layout = QVBoxLayout()
browser = QtGui.QTextBrowser() browser = QtGui.QTextBrowser()
browser.setOpenLinks(False) browser.setOpenLinks(False)
@ -50,7 +50,7 @@ class CouldNotLoadResultsDialog(QtGui.QDialog):
html = self.alg.getPostProcessingErrorMessage(self.wrongLayers) html = self.alg.getPostProcessingErrorMessage(self.wrongLayers)
browser.setHtml(html) browser.setHtml(html)
button = QPushButton() button = QPushButton()
button.setText('Close') button.setText(self.tr('Close'))
button.clicked.connect(self.closeButtonPressed) button.clicked.connect(self.closeButtonPressed)
buttonBox = QtGui.QDialogButtonBox() buttonBox = QtGui.QDialogButtonBox()
buttonBox.setOrientation(QtCore.Qt.Horizontal) buttonBox.setOrientation(QtCore.Qt.Horizontal)

View File

@ -37,7 +37,7 @@ class CreateNewScriptAction(ToolboxAction):
def __init__(self, actionName, scriptType): def __init__(self, actionName, scriptType):
self.name = actionName self.name = actionName
self.group = 'Tools' self.group = self.tr('Tools', 'CreateNewScriptAction')
self.scriptType = scriptType self.scriptType = scriptType
def getIcon(self): def getIcon(self):

View File

@ -53,7 +53,8 @@ class DeleteScriptAction(ContextAction):
def execute(self, alg): def execute(self, alg):
reply = QMessageBox.question(None, reply = QMessageBox.question(None,
self.tr('Confirmation', 'DeleteScriptAction'), self.tr('Confirmation', 'DeleteScriptAction'),
self.tr('Are you sure you want to delete this script?', 'DeleteScriptAction'), self.tr('Are you sure you want to delete this script?',
'DeleteScriptAction'),
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) QMessageBox.No)
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:

View File

@ -51,7 +51,7 @@ class ExtentSelectionPanel(QtGui.QWidget):
if self.canUseAutoExtent(): if self.canUseAutoExtent():
if hasattr(self.text, 'setPlaceholderText'): if hasattr(self.text, 'setPlaceholderText'):
self.text.setPlaceholderText( self.text.setPlaceholderText(
'[Leave blank to use min covering extent]') self.tr('[Leave blank to use min covering extent]'))
self.horizontalLayout.addWidget(self.text) self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton() self.pushButton = QtGui.QPushButton()
self.pushButton.setText('...') self.pushButton.setText('...')
@ -74,17 +74,17 @@ class ExtentSelectionPanel(QtGui.QWidget):
def buttonPushed(self): def buttonPushed(self):
popupmenu = QMenu() popupmenu = QMenu()
useLayerExtentAction = QtGui.QAction('Use layer/canvas extent', useLayerExtentAction = QtGui.QAction(self.tr('Use layer/canvas extent'),
self.pushButton) self.pushButton)
useLayerExtentAction.triggered.connect(self.useLayerExtent) useLayerExtentAction.triggered.connect(self.useLayerExtent)
popupmenu.addAction(useLayerExtentAction) popupmenu.addAction(useLayerExtentAction)
selectOnCanvasAction = QtGui.QAction('Select extent on canvas', selectOnCanvasAction = QtGui.QAction(self.tr('Select extent on canvas'),
self.pushButton) self.pushButton)
selectOnCanvasAction.triggered.connect(self.selectOnCanvas) selectOnCanvasAction.triggered.connect(self.selectOnCanvas)
popupmenu.addAction(selectOnCanvasAction) popupmenu.addAction(selectOnCanvasAction)
if self.canUseAutoExtent(): if self.canUseAutoExtent():
useMincoveringExtentAction = \ useMincoveringExtentAction = \
QtGui.QAction('Use min covering extent from input layers', QtGui.QAction(self.tr('Use min covering extent from input layers'),
self.pushButton) self.pushButton)
useMincoveringExtentAction.triggered.connect( useMincoveringExtentAction.triggered.connect(
self.useMinCoveringExtent) self.useMinCoveringExtent)

View File

@ -44,7 +44,7 @@ class FileSelectionPanel(QtGui.QWidget):
QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.text) self.horizontalLayout.addWidget(self.text)
self.pushButton = QtGui.QPushButton() self.pushButton = QtGui.QPushButton()
self.pushButton.setText('...') self.pushButton.setText(self.tr('...'))
self.pushButton.clicked.connect(self.showSelectionDialog) self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton) self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout) self.setLayout(self.horizontalLayout)
@ -64,13 +64,13 @@ class FileSelectionPanel(QtGui.QWidget):
if self.isFolder: if self.isFolder:
folder = QtGui.QFileDialog.getExistingDirectory(self, folder = QtGui.QFileDialog.getExistingDirectory(self,
'Select folder', path) self.tr('Select folder'), path)
if folder: if folder:
self.text.setText(str(folder)) self.text.setText(str(folder))
settings.setValue('/Processing/LastInputPath', settings.setValue('/Processing/LastInputPath',
os.path.dirname(unicode(folder))) os.path.dirname(unicode(folder)))
else: else:
filenames = QtGui.QFileDialog.getOpenFileNames(self, 'Open file', filenames = QtGui.QFileDialog.getOpenFileNames(self, self.tr('Open file'),
path, '*.' + self.ext) path, '*.' + self.ext)
if filenames: if filenames:
self.text.setText(u';'.join(filenames)) self.text.setText(u';'.join(filenames))

View File

@ -42,7 +42,7 @@ class FixedTableDialog(QtGui.QDialog):
def setupUi(self): def setupUi(self):
self.resize(600, 350) self.resize(600, 350)
self.setWindowTitle('Fixed Table') self.setWindowTitle(self.tr('Fixed Table'))
self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
@ -62,10 +62,10 @@ class FixedTableDialog(QtGui.QDialog):
self.table.setRowHeight(i, 22) self.table.setRowHeight(i, 22)
self.table.verticalHeader().setVisible(False) self.table.verticalHeader().setVisible(False)
self.addRowButton = QtGui.QPushButton() self.addRowButton = QtGui.QPushButton()
self.addRowButton.setText('Add row') self.addRowButton.setText(self.tr('Add row'))
self.addRowButton.setEnabled(not self.param.fixedNumOfRows) self.addRowButton.setEnabled(not self.param.fixedNumOfRows)
self.removeRowButton = QtGui.QPushButton() self.removeRowButton = QtGui.QPushButton()
self.removeRowButton.setText('Remove row') self.removeRowButton.setText(self.tr('Remove row'))
self.removeRowButton.setEnabled(not self.param.fixedNumOfRows) self.removeRowButton.setEnabled(not self.param.fixedNumOfRows)
self.buttonBox.addButton(self.addRowButton, self.buttonBox.addButton(self.addRowButton,
QtGui.QDialogButtonBox.ActionRole) QtGui.QDialogButtonBox.ActionRole)
@ -108,4 +108,4 @@ class FixedTableDialog(QtGui.QDialog):
self.table.setRowHeight(self.table.rowCount() - 1, 22) self.table.setRowHeight(self.table.rowCount() - 1, 22)
for i in range(self.table.columnCount()): for i in range(self.table.columnCount()):
self.table.setItem(self.table.rowCount() - 1, i, self.table.setItem(self.table.rowCount() - 1, i,
QtGui.QTableWidgetItem('0')) QtGui.QTableWidgetItem('0'))

View File

@ -43,13 +43,12 @@ class FixedTablePanel(QtGui.QWidget):
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
self.label = QtGui.QLabel() self.label = QtGui.QLabel()
self.label.setText('Fixed table ' + str(len(param.cols)) + ' X ' self.label.setText(self.tr('Fixed table %dx%d' % (len(param.cols), param.numRows)))
+ str(param.numRows))
self.label.setSizePolicy(QtGui.QSizePolicy.Expanding, self.label.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.label) self.horizontalLayout.addWidget(self.label)
self.pushButton = QtGui.QPushButton() self.pushButton = QtGui.QPushButton()
self.pushButton.setText('...') self.pushButton.setText(self.tr('...'))
self.pushButton.clicked.connect(self.showFixedTableDialog) self.pushButton.clicked.connect(self.showFixedTableDialog)
self.horizontalLayout.addWidget(self.pushButton) self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout) self.setLayout(self.horizontalLayout)

View File

@ -44,8 +44,8 @@ from processing.gui.Help2Html import getDescription, ALG_DESC, ALG_VERSION, ALG_
class GetScriptsAction(ToolboxAction): class GetScriptsAction(ToolboxAction):
def __init__(self): def __init__(self):
self.name = "Get scripts from on-line scripts collection" self.name = self.tr('Get scripts from on-line scripts collection', 'GetScriptsAction')
self.group = 'Tools' self.group = self.tr('Tools', 'GetScriptsAction')
def getIcon(self): def getIcon(self):
return QIcon(':/processing/images/script.png') return QIcon(':/processing/images/script.png')
@ -58,14 +58,16 @@ class GetScriptsAction(ToolboxAction):
self.toolbox.updateProvider('script') self.toolbox.updateProvider('script')
except HTTPError: except HTTPError:
QMessageBox.critical(iface.mainWindow(), "Connection problem", "Could not connect to scripts/models repository") QMessageBox.critical(iface.mainWindow(),
self.tr('Connection problem', 'GetScriptsAction'),
self.tr('Could not connect to scripts/models repository', 'GetScriptsAction'))
class GetModelsAction(ToolboxAction): class GetModelsAction(ToolboxAction):
def __init__(self): def __init__(self):
self.name = "Get models from on-line scripts collection" self.name = self.tr('Get models from on-line scripts collection', 'GetModelsAction')
self.group = 'Tools' self.group = self.tr('Tools', 'GetModelsAction')
def getIcon(self): def getIcon(self):
return QIcon(':/processing/images/model.png') return QIcon(':/processing/images/model.png')
@ -77,7 +79,9 @@ class GetModelsAction(ToolboxAction):
if dlg.updateToolbox: if dlg.updateToolbox:
self.toolbox.updateProvider('model') self.toolbox.updateProvider('model')
except HTTPError: except HTTPError:
QMessageBox.critical(iface.mainWindow(), "Connection problem", "Could not connect to scripts/models repository") QMessageBox.critical(iface.mainWindow(),
self.tr('Connection problem', 'GetModelsAction'),
self.tr('Could not connect to scripts/models repository', 'GetModelsAction'))
def readUrl(url): def readUrl(url):
@ -109,11 +113,11 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
self.resourceType = resourceType self.resourceType = resourceType
if self.resourceType == self.MODELS: if self.resourceType == self.MODELS:
self.folder = ModelerUtils.modelsFolder() self.folder = ModelerUtils.modelsFolder()
self.urlBase = "https://raw.githubusercontent.com/qgis/QGIS-Processing/master/models/" self.urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/models/'
self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png') self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png')
else: else:
self.folder = ScriptUtils.scriptsFolder() self.folder = ScriptUtils.scriptsFolder()
self.urlBase = "https://raw.githubusercontent.com/qgis/QGIS-Processing/master/scripts/" self.urlBase = 'https://raw.githubusercontent.com/qgis/QGIS-Processing/master/scripts/'
self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/script.png') self.icon = QtGui.QIcon(os.path.dirname(__file__) + '/../images/script.png')
self.lastSelectedItem = None self.lastSelectedItem = None
self.setupUi(self) self.setupUi(self)
@ -125,16 +129,16 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
def populateTree(self): def populateTree(self):
self.uptodateItem = QTreeWidgetItem() self.uptodateItem = QTreeWidgetItem()
self.uptodateItem.setText(0, "Installed") self.uptodateItem.setText(0, self.tr('Installed'))
self.toupdateItem = QTreeWidgetItem() self.toupdateItem = QTreeWidgetItem()
self.toupdateItem.setText(0, "Upgradable") self.toupdateItem.setText(0, self.tr('Upgradable'))
self.notinstalledItem = QTreeWidgetItem() self.notinstalledItem = QTreeWidgetItem()
self.notinstalledItem.setText(0, "Not installed") self.notinstalledItem.setText(0, self.tr('Not installed'))
self.toupdateItem.setIcon(0, self.icon) self.toupdateItem.setIcon(0, self.icon)
self.uptodateItem.setIcon(0, self.icon) self.uptodateItem.setIcon(0, self.icon)
self.notinstalledItem.setIcon(0, self.icon) self.notinstalledItem.setIcon(0, self.icon)
resources = readUrl(self.urlBase + "list.txt").splitlines() resources = readUrl(self.urlBase + 'list.txt').splitlines()
resources = [r.split(",") for r in resources] resources = [r.split(',') for r in resources]
for filename, version, name in resources: for filename, version, name in resources:
treeBranch = self.getTreeBranchForState(filename, float(version)) treeBranch = self.getTreeBranchForState(filename, float(version))
item = TreeItem(filename, name, self.icon) item = TreeItem(filename, name, self.icon)
@ -151,15 +155,15 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
def currentItemChanged(self, item, prev): def currentItemChanged(self, item, prev):
if isinstance(item, TreeItem): if isinstance(item, TreeItem):
try: try:
url = self.urlBase + item.filename.replace(" ","%20") + ".help" url = self.urlBase + item.filename.replace(' ', '%20') + '.help'
helpContent = readUrl(url) helpContent = readUrl(url)
descriptions = json.loads(helpContent) descriptions = json.loads(helpContent)
html = "<h2>%s</h2>" % item.name html = '<h2>%s</h2>' % item.name
html+="<p><b>Description:</b> " + getDescription(ALG_DESC, descriptions)+"</p>" html += self.tr('<p><b>Description:</b>%s</p>') % getDescription(ALG_DESC, descriptions)
html+="<p><b>Created by:</b> " + getDescription(ALG_CREATOR, descriptions)+"</p>" html += self.tr('<p><b>Created by:</b>%s') % getDescription(ALG_CREATOR, descriptions)
html+="<p><b>Version:</b> " + getDescription(ALG_VERSION, descriptions)+"</p>" html += self.tr('<p><b>Version:</b>%s') % getDescription(ALG_VERSION, descriptions)
except HTTPError, e: except HTTPError, e:
html = "<h2>No detailed description available for this script</h2>" html = self.tr('<h2>No detailed description available for this script</h2>')
self.webView.setHtml(html) self.webView.setHtml(html)
else: else:
self.webView.setHtml(self.HELP_TEXT) self.webView.setHtml(self.HELP_TEXT)
@ -168,7 +172,7 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
if not os.path.exists(os.path.join(self.folder, filename)): if not os.path.exists(os.path.join(self.folder, filename)):
return self.notinstalledItem return self.notinstalledItem
else: else:
helpFile = os.path.join(self.folder, filename + ".help") helpFile = os.path.join(self.folder, filename + '.help')
try: try:
with open(helpFile) as f: with open(helpFile) as f:
helpContent = json.load(f) helpContent = json.load(f)
@ -199,16 +203,17 @@ class GetScriptsAndModelsDialog(QDialog, Ui_DlgGetScriptsAndModels):
self.progressBar.setMaximum(len(toDownload)) self.progressBar.setMaximum(len(toDownload))
for i, filename in enumerate(toDownload): for i, filename in enumerate(toDownload):
QCoreApplication.processEvents() QCoreApplication.processEvents()
url = self.urlBase + filename.replace(" ","%20") url = self.urlBase + filename.replace(' ','%20')
try: try:
code = readUrl(url) code = readUrl(url)
path = os.path.join(self.folder, filename) path = os.path.join(self.folder, filename)
with open(path, "w") as f: with open(path, 'w') as f:
f.write(code) f.write(code)
self.progressBar.setValue(i + 1) self.progressBar.setValue(i + 1)
except HTTPError: except HTTPError:
QMessageBox.critical(iface.mainWindow(), "Connection problem", QMessageBox.critical(iface.mainWindow(),
"Could not download file :" + filename) self.tr('Connection problem'),
self.tr('Could not download file: %s') % filename)
return return

View File

@ -68,20 +68,20 @@ def getHtmlFromHelpFile(alg, helpFile):
def getHtmlFromDescriptionsDict(alg, descriptions): def getHtmlFromDescriptionsDict(alg, descriptions):
s = '<html><body><h2>Algorithm description</h2>\n' s = tr('<html><body><h2>Algorithm description</h2>\n')
s += '<p>' + getDescription(ALG_DESC, descriptions) + '</p>\n' s += '<p>' + getDescription(ALG_DESC, descriptions) + '</p>\n'
s += '<h2>Input parameters</h2>\n' s += tr('<h2>Input parameters</h2>\n')
for param in alg.parameters: for param in alg.parameters:
s += '<h3>' + param.description + '</h3>\n' s += '<h3>' + param.description + '</h3>\n'
s += '<p>' + getDescription(param.name, descriptions) + '</p>\n' s += '<p>' + getDescription(param.name, descriptions) + '</p>\n'
s += '<h2>Outputs</h2>\n' s += tr('<h2>Outputs</h2>\n')
for out in alg.outputs: for out in alg.outputs:
s += '<h3>' + out.description + '</h3>\n' s += '<h3>' + out.description + '</h3>\n'
s += '<p>' + getDescription(out.name, descriptions) + '</p>\n' s += '<p>' + getDescription(out.name, descriptions) + '</p>\n'
s += '<br>' s += '<br>'
s += '<p align="right">Algorithm author: ' + getDescription(ALG_CREATOR, descriptions) + '</p>' s += tr('<p align="right">Algorithm author: %s</p>') % getDescription(ALG_CREATOR, descriptions)
s += '<p align="right">Help author: ' + getDescription(ALG_HELP_CREATOR, descriptions) + '</p>' s += tr('<p align="right">Help author: %s</p>') + getDescription(ALG_HELP_CREATOR, descriptions)
s += '<p align="right">Algorithm version: ' + getDescription(ALG_VERSION, descriptions) + '</p>' s += tr('<p align="right">Algorithm version: %s</p>') + getDescription(ALG_VERSION, descriptions)
s += '</body></html>' s += '</body></html>'
return s return s
@ -92,3 +92,5 @@ def getDescription(name, descriptions):
else: else:
return '' return ''
def tr(string):
return QtCore.QCoreApplication.translate('Help2Html', string)

View File

@ -58,7 +58,8 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
with open(helpfile) as f: with open(helpfile) as f:
self.descriptions = json.load(f) self.descriptions = json.load(f)
except Exception, e: except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_WARNING, "Cannot open help file: " + helpfile) ProcessingLog.addToLog(ProcessingLog.LOG_WARNING,
self.tr('Cannot open help file: %s') % helpfile)
self.currentName = self.ALG_DESC self.currentName = self.ALG_DESC
if self.ALG_DESC in self.descriptions: if self.ALG_DESC in self.descriptions:
@ -82,32 +83,32 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
with open(self.alg.descriptionFile + '.help', 'w') as f: with open(self.alg.descriptionFile + '.help', 'w') as f:
json.dump(self.descriptions, f) json.dump(self.descriptions, f)
except Exception, e: except Exception, e:
QMessageBox.warning(self, 'Error saving help file', QMessageBox.warning(self, self.tr('Error saving help file'),
'Help file could not be saved.\n' self.tr('Help file could not be saved.\n'
'Check that you have permission to modify the help\n' 'Check that you have permission to modify the help\n'
'file. You might not have permission if you are \n' 'file. You might not have permission if you are \n'
'editing an example model or script, since they \n' 'editing an example model or script, since they \n'
'are stored on the installation folder') 'are stored on the installation folder'))
QDialog.accept(self) QDialog.accept(self)
def getHtml(self): def getHtml(self):
s = '<h2>Algorithm description</h2>\n' s = self.tr('<h2>Algorithm description</h2>\n')
s += '<p>' + self.getDescription(self.ALG_DESC) + '</p>\n' s += '<p>' + self.getDescription(self.ALG_DESC) + '</p>\n'
s += '<h2>Input parameters</h2>\n' s += self.tr('<h2>Input parameters</h2>\n')
for param in self.alg.parameters: for param in self.alg.parameters:
s += '<h3>' + param.description + '</h3>\n' s += '<h3>' + param.description + '</h3>\n'
s += '<p>' + self.getDescription(param.name) + '</p>\n' s += '<p>' + self.getDescription(param.name) + '</p>\n'
s += '<h2>Outputs</h2>\n' s += self.tr('<h2>Outputs</h2>\n')
for out in self.alg.outputs: for out in self.alg.outputs:
s += '<h3>' + out.description + '</h3>\n' s += '<h3>' + out.description + '</h3>\n'
s += '<p>' + self.getDescription(out.name) + '</p>\n' s += '<p>' + self.getDescription(out.name) + '</p>\n'
return s return s
def fillTree(self): def fillTree(self):
item = TreeDescriptionItem('Algorithm description', self.ALG_DESC) item = TreeDescriptionItem(self.tr('Algorithm description'), self.ALG_DESC)
self.tree.addTopLevelItem(item) self.tree.addTopLevelItem(item)
parametersItem = TreeDescriptionItem('Input parameters', None) parametersItem = TreeDescriptionItem(self.tr('Input parameters'), None)
self.tree.addTopLevelItem(parametersItem) self.tree.addTopLevelItem(parametersItem)
for param in self.alg.parameters: for param in self.alg.parameters:
item = TreeDescriptionItem(param.description, param.name) item = TreeDescriptionItem(param.description, param.name)
@ -117,12 +118,12 @@ class HelpEditionDialog(QDialog, Ui_DlgHelpEdition):
for out in self.alg.outputs: for out in self.alg.outputs:
item = TreeDescriptionItem(out.description, out.name) item = TreeDescriptionItem(out.description, out.name)
outputsItem.addChild(item) outputsItem.addChild(item)
item = TreeDescriptionItem('Algorithm created by', self.ALG_CREATOR) item = TreeDescriptionItem(self.tr('Algorithm created by'), self.ALG_CREATOR)
self.tree.addTopLevelItem(item) self.tree.addTopLevelItem(item)
item = TreeDescriptionItem('Algorithm help written by', item = TreeDescriptionItem(self.tr('Algorithm help written by'),
self.ALG_HELP_CREATOR) self.ALG_HELP_CREATOR)
self.tree.addTopLevelItem(item) self.tree.addTopLevelItem(item)
item = TreeDescriptionItem('Algorithm version', item = TreeDescriptionItem(self.tr('Algorithm version'),
self.ALG_VERSION) self.ALG_VERSION)
self.tree.addTopLevelItem(item) self.tree.addTopLevelItem(item)

View File

@ -77,7 +77,7 @@ class HistoryDialog(QDialog, Ui_DlgHistory):
def saveLog(self): def saveLog(self):
fileName = QFileDialog.getSaveFileName(self, fileName = QFileDialog.getSaveFileName(self,
self.tr('Save file'), '.', 'Log files (*.log *.LOG)') self.tr('Save file'), '.', self.tr('Log files (*.log *.LOG)'))
if fileName == '': if fileName == '':
return return

View File

@ -63,7 +63,7 @@ class InputLayerSelectorPanel(QtGui.QWidget):
path = '' path = ''
filename = QtGui.QFileDialog.getOpenFileName(self, self.param.description, path, filename = QtGui.QFileDialog.getOpenFileName(self, self.param.description, path,
'All files(*.*);;' + self.param.getFileFilter()) self.tr('All files(*.*);;') + self.param.getFileFilter())
if filename: if filename:
self.text.addItem(filename, filename) self.text.addItem(filename, filename)
self.text.setCurrentIndex(self.text.count() - 1) self.text.setCurrentIndex(self.text.count() - 1)

View File

@ -45,9 +45,8 @@ class MessageBarProgress:
def error(self, msg): def error(self, msg):
iface.messageBar().clearWidgets() iface.messageBar().clearWidgets()
iface.messageBar().pushMessage("Error", msg, iface.messageBar().pushMessage(self.tr('Error'),
level = QgsMessageBar.CRITICAL, msg, level=QgsMessageBar.CRITICAL, duration=3)
duration = 3)
def setText(self, text): def setText(self, text):
pass pass

View File

@ -36,21 +36,20 @@ class MissingDependencyDialog(QtGui.QDialog):
def __init__(self, msg): def __init__(self, msg):
QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint QtGui.QDialog.__init__(self, None, QtCore.Qt.WindowSystemMenuHint
| QtCore.Qt.WindowTitleHint) | QtCore.Qt.WindowTitleHint)
self.msg = \ self.msg = self.tr('<h3>Missing dependency.This algorithm cannot '
'<h3>Missing dependency.This algorithm cannot be run :-( </h3>' \ 'be run :-( </h3>\n%s') % msg
+ msg
self.setupUi() self.setupUi()
def setupUi(self): def setupUi(self):
self.resize(500, 300) self.resize(500, 300)
self.setWindowTitle('Missing dependency') self.setWindowTitle(self.tr('Missing dependency'))
layout = QVBoxLayout() layout = QVBoxLayout()
browser = QtGui.QTextBrowser() browser = QtGui.QTextBrowser()
browser.setOpenLinks(False) browser.setOpenLinks(False)
browser.anchorClicked.connect(self.linkClicked) browser.anchorClicked.connect(self.linkClicked)
browser.setHtml(self.msg) browser.setHtml(self.msg)
button = QPushButton() button = QPushButton()
button.setText('Close') button.setText(self.tr('Close'))
button.clicked.connect(self.closeButtonPressed) button.clicked.connect(self.closeButtonPressed)
buttonBox = QtGui.QDialogButtonBox() buttonBox = QtGui.QDialogButtonBox()
buttonBox.setOrientation(QtCore.Qt.Horizontal) buttonBox.setOrientation(QtCore.Qt.Horizontal)

View File

@ -42,7 +42,7 @@ class MultipleFileInputDialog(QtGui.QDialog):
def setupUi(self): def setupUi(self):
self.resize(381, 320) self.resize(381, 320)
self.setWindowTitle("Multiple selection") self.setWindowTitle(self.tr("Multiple selection"))
self.horizontalLayout = QtGui.QHBoxLayout(self) self.horizontalLayout = QtGui.QHBoxLayout(self)
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
@ -92,7 +92,8 @@ class MultipleFileInputDialog(QtGui.QDialog):
else : else :
path = QtCore.QDir.currentPath() path = QtCore.QDir.currentPath()
filesOpened = QtGui.QFileDialog.getOpenFileNames( None, "Select the file(s) to use", path, "All files (*.*)" ) filesOpened = QtGui.QFileDialog.getOpenFileNames(None,
self.tr('Select the file(s) to use'), path, self.tr('All files (*.*)'))
lastfile = "" lastfile = ""
for item in filesOpened: for item in filesOpened:

View File

@ -39,11 +39,11 @@ class MultipleFileInputPanel(QtGui.QWidget):
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
self.label = QtGui.QLabel() self.label = QtGui.QLabel()
self.label.setText("0 elements selected") self.label.setText(self.tr('0 elements selected'))
self.label.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) self.label.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
self.horizontalLayout.addWidget(self.label) self.horizontalLayout.addWidget(self.label)
self.pushButton = QtGui.QPushButton() self.pushButton = QtGui.QPushButton()
self.pushButton.setText("...") self.pushButton.setText(self.tr('...'))
self.pushButton.clicked.connect(self.showSelectionDialog) self.pushButton.clicked.connect(self.showSelectionDialog)
self.horizontalLayout.addWidget(self.pushButton) self.horizontalLayout.addWidget(self.pushButton)
self.setLayout(self.horizontalLayout) self.setLayout(self.horizontalLayout)
@ -51,11 +51,11 @@ class MultipleFileInputPanel(QtGui.QWidget):
def setSelectedItems(self, selected): def setSelectedItems(self, selected):
#no checking is performed! #no checking is performed!
self.selectedoptions = selected self.selectedoptions = selected
self.label.setText(str(len(self.selectedoptions)) + " elements selected") self.label.setText(self.tr('%d elements selected') % len(self.selectedoptions))
def showSelectionDialog(self): def showSelectionDialog(self):
dlg = MultipleFileInputDialog(self.selectedoptions) dlg = MultipleFileInputDialog(self.selectedoptions)
dlg.exec_() dlg.exec_()
if dlg.selectedoptions != None: if dlg.selectedoptions != None:
self.selectedoptions = dlg.selectedoptions self.selectedoptions = dlg.selectedoptions
self.label.setText(str(len(self.selectedoptions)) + " elements selected") self.label.setText(self.tr('%d elements selected') % len(self.selectedoptions))

View File

@ -36,10 +36,11 @@ class ParametersDialog(AlgorithmExecutionDialog):
NOT_SELECTED = QtCore.QCoreApplication.translate('ParametersDialog', '[Not selected]') NOT_SELECTED = QtCore.QCoreApplication.translate('ParametersDialog', '[Not selected]')
def __init__(self, alg): def __init__(self, alg):
AlgorithmExecutionDialog.__init__(self, alg, self.scrollArea)
self.paramTable = ParametersPanel(self, alg) self.paramTable = ParametersPanel(self, alg)
self.scrollArea = QtGui.QScrollArea() self.scrollArea = QtGui.QScrollArea()
self.scrollArea.setFrameShape(QtGui.QFrame.NoFrame); self.scrollArea.setFrameShape(QtGui.QFrame.NoFrame);
self.scrollArea.setWidget(self.paramTable) self.scrollArea.setWidget(self.paramTable)
self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidgetResizable(True)
AlgorithmExecutionDialog.__init__(self, alg, self.scrollArea)
self.executed = False self.executed = False

View File

@ -71,7 +71,7 @@ from processing.tools import dataobjects
class ParametersPanel(QWidget): class ParametersPanel(QWidget):
NOT_SELECTED = '[Not selected]' NOT_SELECTED = QCoreApplication.translate('ParametersPanel', '[Not selected]')
def __init__(self, parent, alg): def __init__(self, parent, alg):
super(ParametersPanel, self).__init__(None) super(ParametersPanel, self).__init__(None)
@ -96,7 +96,7 @@ class ParametersPanel(QWidget):
for param in self.alg.parameters: for param in self.alg.parameters:
if param.isAdvanced: if param.isAdvanced:
self.advancedButton = QPushButton() self.advancedButton = QPushButton()
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
self.advancedButton.setMaximumWidth(250) self.advancedButton.setMaximumWidth(250)
self.advancedButton.clicked.connect( self.advancedButton.clicked.connect(
self.showAdvancedParametersClicked) self.showAdvancedParametersClicked)
@ -110,7 +110,7 @@ class ParametersPanel(QWidget):
desc += ' (xmin, xmax, ymin, ymax)' desc += ' (xmin, xmax, ymin, ymax)'
try: try:
if param.optional: if param.optional:
desc += ' [optional]' desc += self.tr(' [optional]')
except: except:
pass pass
widget = self.getWidgetFromParameter(param) widget = self.getWidgetFromParameter(param)
@ -126,7 +126,7 @@ class ParametersPanel(QWidget):
icon = QIcon(os.path.dirname(__file__) icon = QIcon(os.path.dirname(__file__)
+ '/../images/iterate.png') + '/../images/iterate.png')
button.setIcon(icon) button.setIcon(icon)
button.setToolTip('Iterate over this layer') button.setToolTip(self.tr('Iterate over this layer'))
button.setCheckable(True) button.setCheckable(True)
button.setMaximumWidth(30) button.setMaximumWidth(30)
button.setMaximumHeight(30) button.setMaximumHeight(30)
@ -169,7 +169,7 @@ class ParametersPanel(QWidget):
self.verticalLayout.addWidget(widget) self.verticalLayout.addWidget(widget)
if isinstance(output, (OutputRaster, OutputVector, OutputTable)): if isinstance(output, (OutputRaster, OutputVector, OutputTable)):
check = QCheckBox() check = QCheckBox()
check.setText('Open output file after running algorithm') check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True) check.setChecked(True)
self.verticalLayout.addWidget(check) self.verticalLayout.addWidget(check)
self.checkBoxes[output.name] = check self.checkBoxes[output.name] = check
@ -181,9 +181,9 @@ class ParametersPanel(QWidget):
def showAdvancedParametersClicked(self): def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced self.showAdvanced = not self.showAdvanced
if self.showAdvanced: if self.showAdvanced:
self.advancedButton.setText('Hide advanced parameters') self.advancedButton.setText(self.tr('Hide advanced parameters'))
else: else:
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
for param in self.alg.parameters: for param in self.alg.parameters:
if param.isAdvanced: if param.isAdvanced:
self.labels[param.name].setVisible(self.showAdvanced) self.labels[param.name].setVisible(self.showAdvanced)
@ -280,7 +280,7 @@ class ParametersPanel(QWidget):
layers = dataobjects.getTables() layers = dataobjects.getTables()
if len(layers) > 0: if len(layers) > 0:
if param.optional: if param.optional:
item.addItem("[not set]") item.addItem(self.tr("[not set]"))
item.addItems(self.getFields(layers[0], param.datatype)) item.addItems(self.getFields(layers[0], param.datatype))
elif isinstance(param, ParameterSelection): elif isinstance(param, ParameterSelection):
item = QComboBox() item = QComboBox()
@ -343,7 +343,7 @@ class ParametersPanel(QWidget):
widget = self.valueItems[child] widget = self.valueItems[child]
widget.clear() widget.clear()
if self.alg.getParameterFromName(child).optional: if self.alg.getParameterFromName(child).optional:
widget.addItem("[not set]") widget.addItem(self.tr("[not set]"))
widget.addItems(self.getFields(layer, widget.addItems(self.getFields(layer,
self.alg.getParameterFromName(child).datatype)) self.alg.getParameterFromName(child).datatype))

View File

@ -27,6 +27,7 @@ __revision__ = '$Format:%H$'
import os import os
from PyQt4.QtGui import * from PyQt4.QtGui import *
from PyQt4.QtCore import *
from qgis.core import * from qgis.core import *
from processing.gui.SilentProgress import SilentProgress from processing.gui.SilentProgress import SilentProgress
from processing.core.ProcessingConfig import ProcessingConfig from processing.core.ProcessingConfig import ProcessingConfig
@ -45,7 +46,7 @@ def handleAlgorithmResults(alg, progress=None, showResults=True):
htmlResults = False htmlResults = False
if progress is None: if progress is None:
progress = SilentProgress() progress = SilentProgress()
progress.setText('Loading resulting layers') progress.setText(QCoreApplication.translate('Postprocessing', 'Loading resulting layers'))
i = 0 i = 0
for out in alg.outputs: for out in alg.outputs:
progress.setPercentage(100 * i / float(len(alg.outputs))) progress.setPercentage(100 * i / float(len(alg.outputs)))

View File

@ -36,12 +36,12 @@ class RangePanel(QtGui.QWidget):
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
self.labelmin = QtGui.QLabel() self.labelmin = QtGui.QLabel()
self.labelmin.setText('Min') self.labelmin.setText(self.tr('Min'))
self.textmin = QtGui.QLineEdit() self.textmin = QtGui.QLineEdit()
self.textmin.setSizePolicy(QtGui.QSizePolicy.Expanding, self.textmin.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding) QtGui.QSizePolicy.Expanding)
self.labelmax = QtGui.QLabel() self.labelmax = QtGui.QLabel()
self.labelmax.setText('Max') self.labelmax.setText(self.tr('Max'))
self.textmax = QtGui.QLineEdit() self.textmax = QtGui.QLineEdit()
self.textmin.setText(param.default.split(',')[0]) self.textmin.setText(param.default.split(',')[0])
self.textmax.setText(param.default.split(',')[1]) self.textmax.setText(param.default.split(',')[1])

View File

@ -48,8 +48,8 @@ class RenderingStyleFilePanel(QtGui.QWidget):
self.setLayout(self.horizontalLayout) self.setLayout(self.horizontalLayout)
def showSelectionDialog(self): def showSelectionDialog(self):
filename = QtGui.QFileDialog.getOpenFileName(self, 'Select style file' filename = QtGui.QFileDialog.getOpenFileName(self,
, '', '*.qml') self.tr('Select style file'), '', self.tr('QGIS Layer Style File (*.qml *.QML)'))
if filename: if filename:
self.text.setText(unicode(filename)) self.text.setText(unicode(filename))

View File

@ -64,9 +64,9 @@ def createTest(text):
for out in alg.outputs: for out in alg.outputs:
filename = (tokens[i])[1:-1] filename = (tokens[i])[1:-1]
if tokens[i] == str(None): if tokens[i] == str(None):
QtGui.QMessageBox.critical(None, 'Error', QtGui.QMessageBox.critical(None, tr('Error'),
'Cannot create unit test for that algorithm \ tr('Cannot create unit test for that algorithm execution. The '
execution.\nThe output cannot be a temporary file') 'output cannot be a temporary file'))
return return
s += "\toutput=outputs['" + out.name + "']\n" s += "\toutput=outputs['" + out.name + "']\n"
if isinstance(out, (OutputNumber, OutputString)): if isinstance(out, (OutputNumber, OutputString)):
@ -111,6 +111,9 @@ def createTest(text):
dlg = ShowTestDialog(s) dlg = ShowTestDialog(s)
dlg.exec_() dlg.exec_()
def tr(string):
return QCoreApplication.translate('TestTools', string)
class ShowTestDialog(QtGui.QDialog): class ShowTestDialog(QtGui.QDialog):
@ -118,7 +121,7 @@ class ShowTestDialog(QtGui.QDialog):
QtGui.QDialog.__init__(self) QtGui.QDialog.__init__(self)
self.setModal(True) self.setModal(True)
self.resize(600, 400) self.resize(600, 400)
self.setWindowTitle('Unit test') self.setWindowTitle(self.tr('Unit test'))
layout = QVBoxLayout() layout = QVBoxLayout()
self.text = QtGui.QTextEdit() self.text = QtGui.QTextEdit()
self.text.setEnabled(True) self.text.setEnabled(True)

View File

@ -36,23 +36,28 @@ from processing.modeler.ModelerUtils import ModelerUtils
class AddModelFromFileAction(ToolboxAction): class AddModelFromFileAction(ToolboxAction):
def __init__(self): def __init__(self):
self.name = "Add model from file" self.name = self.tr('Add model from file', 'AddModelFromFileAction')
self.group = 'Tools' self.group = self.tr('Tools', 'AddModelFromFileAction')
def getIcon(self): def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png') return QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png')
def execute(self): def execute(self):
filename = QtGui.QFileDialog.getOpenFileName(self.toolbox, 'model files', None, filename = QtGui.QFileDialog.getOpenFileName(self.toolbox,
'*.model') self.tr('Open model', 'AddModelFromFileAction'), None,
self.tr('Processing model files (*.model *.MODEL)', 'AddModelFromFileAction'))
if filename: if filename:
try: try:
ModelerAlgorithm.fromFile(filename) ModelerAlgorithm.fromFile(filename)
except WrongModelException: except WrongModelException:
QtGui.QMessageBox.warning(self.toolbox, "Error reading model", "The selected file does not contain a valid model") QtGui.QMessageBox.warning(self.toolbox,
self.tr('Error reading model', 'AddModelFromFileAction'),
self.tr('The selected file does not contain a valid model', 'AddModelFromFileAction'))
return return
except: except:
QtGui.QMessageBox.warning(self.toolbox, "Error reading model", "Cannot read file") QtGui.QMessageBox.warning(self.toolbox,
self.tr('Error reading model', 'AddModelFromFileAction'),
self.tr('Cannot read file', 'AddModelFromFileAction'))
destFilename = os.path.join(ModelerUtils.modelsFolder(), os.path.basename(filename)) destFilename = os.path.join(ModelerUtils.modelsFolder(), os.path.basename(filename))
shutil.copyfile(filename,destFilename) shutil.copyfile(filename,destFilename)
self.toolbox.updateProvider('script') self.toolbox.updateProvider('model')

View File

@ -46,13 +46,15 @@ class CalculatorModelerAlgorithm(GeoAlgorithm):
def defineCharacteristics(self): def defineCharacteristics(self):
self.showInModeler = True self.showInModeler = True
self.showInToolbox = False self.showInToolbox = False
self.name = 'Calculator' self.name = self.tr('Calculator', 'CalculatorModelerAlgorithm')
self.group = 'Modeler-only tools' self.group = self.tr('Modeler-only tools', 'CalculatorModelerAlgorithm')
self.addParameter(ParameterString(FORMULA, 'Formula', '')) self.addParameter(ParameterString(FORMULA,
self.tr('Formula', 'CalculatorModelerAlgorithm'), ''))
for i in range(AVAILABLE_VARIABLES): for i in range(AVAILABLE_VARIABLES):
self.addParameter(ParameterNumber(NUMBER self.addParameter(ParameterNumber(NUMBER
+ str(i), 'dummy')) + str(i), 'dummy'))
self.addOutput(OutputNumber(RESULT, 'Result')) self.addOutput(OutputNumber(RESULT,
self.tr('Result', 'CalculatorModelerAlgorithm')))
def processAlgorithm(self, progress): def processAlgorithm(self, progress):
formula = self.getParameterValue(FORMULA) formula = self.getParameterValue(FORMULA)
@ -64,7 +66,8 @@ class CalculatorModelerAlgorithm(GeoAlgorithm):
result = eval(formula) result = eval(formula)
self.setOutputValue(RESULT, result) self.setOutputValue(RESULT, result)
except: except:
raise GeoAlgorithmExecutionException('Wrong formula: ' + formula) raise GeoAlgorithmExecutionException(
self.tr('Wrong formula: %s', 'CalculatorModelerAlgorithm') % formula)
def getCustomModelerParametersDialog(self, modelAlg, algIndex=None): def getCustomModelerParametersDialog(self, modelAlg, algIndex=None):
return CalculatorModelerParametersDialog(self, modelAlg, algIndex) return CalculatorModelerParametersDialog(self, modelAlg, algIndex)
@ -82,21 +85,21 @@ class CalculatorModelerParametersDialog(ModelerParametersDialog):
| QtGui.QDialogButtonBox.Ok) | QtGui.QDialogButtonBox.Ok)
self.infoText = QtGui.QTextEdit() self.infoText = QtGui.QTextEdit()
numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber) numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber)
text = ('You can refer to model values in you formula, using' text = self.tr('You can refer to model values in you formula, using'
'single-letter variables, as follows:\n') 'single-letter variables, as follows:\n', 'CalculatorModelerParametersDialog')
ichar = 97 ichar = 97
if numbers: if numbers:
for number in numbers: for number in numbers:
text += chr(ichar) + '->' + self.resolveValueDescription(number) + '\n' text += chr(ichar) + '->' + self.resolveValueDescription(number) + '\n'
ichar += 1 ichar += 1
else: else:
text += "\n - No numerical variables are available." text += self.tr('\n - No numerical variables are available.', 'CalculatorModelerParametersDialog')
self.infoText.setText(text) self.infoText.setText(text)
self.infoText.setEnabled(False) self.infoText.setEnabled(False)
self.formulaText = QtGui.QLineEdit() self.formulaText = QtGui.QLineEdit()
if hasattr(self.formulaText, 'setPlaceholderText'): if hasattr(self.formulaText, 'setPlaceholderText'):
self.formulaText.setPlaceholderText('[Enter your formula here]') self.formulaText.setPlaceholderText(self.tr('[Enter your formula here]', 'CalculatorModelerParametersDialog'))
self.setWindowTitle("Calculator") self.setWindowTitle(self.tr('Calculator', 'CalculatorModelerParametersDialog'))
self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout = QtGui.QVBoxLayout()
self.verticalLayout.setSpacing(2) self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0) self.verticalLayout.setMargin(0)
@ -113,7 +116,7 @@ class CalculatorModelerParametersDialog(ModelerParametersDialog):
def createAlgorithm(self): def createAlgorithm(self):
alg = Algorithm('modelertools:calculator') alg = Algorithm('modelertools:calculator')
alg.setName(self.model) alg.setName(self.model)
alg.description = "Calculator" alg.description = self.tr('Calculator', 'CalculatorModelerParametersDialog')
formula = self.formulaText.text() formula = self.formulaText.text()
alg.params[FORMULA] = formula alg.params[FORMULA] = formula

View File

@ -33,8 +33,8 @@ from processing.modeler.ModelerDialog import ModelerDialog
class CreateNewModelAction(ToolboxAction): class CreateNewModelAction(ToolboxAction):
def __init__(self): def __init__(self):
self.name = 'Create new model' self.name = self.tr('Create new model', 'CreateNewModelAction')
self.group = 'Tools' self.group = self.tr('Tools', 'CreateNewModelAction')
def getIcon(self): def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png') return QtGui.QIcon(os.path.dirname(__file__) + '/../images/model.png')

View File

@ -34,14 +34,15 @@ from processing.modeler.ModelerAlgorithm import ModelerAlgorithm
class DeleteModelAction(ContextAction): class DeleteModelAction(ContextAction):
def __init__(self): def __init__(self):
self.name = 'Delete model' self.name = self.tr('Delete model', 'DeleteModelAction')
def isEnabled(self): def isEnabled(self):
return isinstance(self.alg, ModelerAlgorithm) return isinstance(self.alg, ModelerAlgorithm)
def execute(self): def execute(self):
reply = QtGui.QMessageBox.question(None, 'Confirmation', reply = QtGui.QMessageBox.question(None,
'Are you sure you want to delete this model?', self.tr('Confirmation', 'DeleteModelAction'),
self.tr('Are you sure you want to delete this model?', 'DeleteModelAction'),
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
QtGui.QMessageBox.No) QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes: if reply == QtGui.QMessageBox.Yes:

View File

@ -32,7 +32,7 @@ from processing.modeler.ModelerDialog import ModelerDialog
class EditModelAction(ContextAction): class EditModelAction(ContextAction):
def __init__(self): def __init__(self):
self.name = 'Edit model' self.name = self.tr('Edit model', 'EditModelAction')
def isEnabled(self): def isEnabled(self):
return isinstance(self.alg, ModelerAlgorithm) return isinstance(self.alg, ModelerAlgorithm)

View File

@ -170,7 +170,7 @@ class ModelerAlgorithm(GeoAlgorithm):
return newone return newone
def __init__(self): def __init__(self):
self.name = "Model" self.name = self.tr('Model', 'ModelerAlgorithm')
# The dialog where this model is being edited # The dialog where this model is being edited
self.modelerdialog = None self.modelerdialog = None
self.descriptionFile = None self.descriptionFile = None
@ -330,8 +330,8 @@ class ModelerAlgorithm(GeoAlgorithm):
# algorithms to skip some conversion routines # algorithms to skip some conversion routines
if not param.setValue(value) and not isinstance(param, if not param.setValue(value) and not isinstance(param,
ParameterDataObject): ParameterDataObject):
raise GeoAlgorithmExecutionException('Wrong value: ' raise GeoAlgorithmExecutionException(
+ str(value)) self.tr('Wrong value: %s', 'ModelerAlgorithm') % value)
for out in algInstance.outputs: for out in algInstance.outputs:
if not out.hidden: if not out.hidden:
if out.name in alg.outputs: if out.name in alg.outputs:
@ -424,9 +424,11 @@ class ModelerAlgorithm(GeoAlgorithm):
break break
if canExecute: if canExecute:
try: try:
progress.setDebugInfo('Prepare algorithm: ' + alg.name) progress.setDebugInfo(
self.tr('Prepare algorithm: %s', 'ModelerAlgorithm') % alg.name)
self.prepareAlgorithm(alg) self.prepareAlgorithm(alg)
progress.setText('Running %s [%i/%i]' % ( alg.description, len(executed) + 1 ,len(toExecute))) progress.setText(
self.tr('Running %s [%i/%i]', 'ModelerAlgorithm') % (alg.description, len(executed) + 1 ,len(toExecute)))
progress.setDebugInfo('Parameters: ' + ', '.join([unicode(p).strip() progress.setDebugInfo('Parameters: ' + ', '.join([unicode(p).strip()
+ '=' + unicode(p.value) for p in alg.algorithm.parameters])) + '=' + unicode(p.value) for p in alg.algorithm.parameters]))
t0 = time.time() t0 = time.time()
@ -434,15 +436,14 @@ class ModelerAlgorithm(GeoAlgorithm):
dt = time.time() - t0 dt = time.time() - t0
executed.append(alg.name) executed.append(alg.name)
progress.setDebugInfo( progress.setDebugInfo(
'OK. Execution took %0.3f ms (%i outputs).' self.tr('OK. Execution took %0.3f ms (%i outputs).', 'ModelerAlgorithm') % (dt, len(alg.algorithm.outputs)))
% (dt, len(alg.algorithm.outputs)))
except GeoAlgorithmExecutionException, e: except GeoAlgorithmExecutionException, e:
progress.setDebugInfo('Failed') progress.setDebugInfo(self.tr('Failed', 'ModelerAlgorithm'))
raise GeoAlgorithmExecutionException( raise GeoAlgorithmExecutionException(
'Error executing algorithm %s\n%s' % (alg.description, e.msg)) self.tr('Error executing algorithm %s\n%s', 'ModelerAlgorithm') % (alg.description, e.msg))
progress.setDebugInfo( progress.setDebugInfo(
'Model processed ok. Executed %i algorithms total' % len(executed)) self.tr('Model processed ok. Executed %i algorithms total', 'ModelerAlgorithm') % len(executed))
def getAsCommand(self): def getAsCommand(self):
@ -558,8 +559,8 @@ class ModelerAlgorithm(GeoAlgorithm):
if param: if param:
pass pass
else: else:
raise WrongModelException('Error in parameter line: ' raise WrongModelException(
+ line) self.tr('Error in parameter line: %s', 'ModelerAlgorithm') % line)
line = lines.readline().strip('\n') line = lines.readline().strip('\n')
tokens = line.split(',') tokens = line.split(',')
model.addParameter(ModelerParameter(param, QtCore.QPointF( model.addParameter(ModelerParameter(param, QtCore.QPointF(
@ -621,8 +622,8 @@ class ModelerAlgorithm(GeoAlgorithm):
model.addAlgorithm(modelAlg) model.addAlgorithm(modelAlg)
modelAlgs.append(modelAlg.name) modelAlgs.append(modelAlg.name)
else: else:
raise WrongModelException('Error in algorithm name: ' raise WrongModelException(
+ algLine) self.tr('Error in algorithm name: %s', 'ModelerAlgorithm') % algLine)
line = lines.readline().strip('\n').strip('\r') line = lines.readline().strip('\n').strip('\r')
for modelAlg in model.algs.values(): for modelAlg in model.algs.values():
for name, value in modelAlg.params.iteritems(): for name, value in modelAlg.params.iteritems():
@ -633,5 +634,4 @@ class ModelerAlgorithm(GeoAlgorithm):
if isinstance(e, WrongModelException): if isinstance(e, WrongModelException):
raise e raise e
else: else:
raise WrongModelException('Error in model definition line:' raise WrongModelException(self.tr('Error in model definition line: %s\n%s', 'ModelerAlgorithm') % (line.strip(), traceback.format_exc()))
+ line.strip() + ' : ' + traceback.format_exc())

View File

@ -51,8 +51,8 @@ class ModelerAlgorithmProvider(AlgorithmProvider):
def initializeSettings(self): def initializeSettings(self):
AlgorithmProvider.initializeSettings(self) AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(self.getDescription(), ProcessingConfig.addSetting(Setting(self.getDescription(),
ModelerUtils.MODELS_FOLDER, 'Models folder' ModelerUtils.MODELS_FOLDER, self.tr('Models folder', 'ModelerAlgorithmProvider'),
, ModelerUtils.modelsFolder())) ModelerUtils.modelsFolder()))
def setAlgsList(self, algs): def setAlgsList(self, algs):
ModelerUtils.allAlgs = algs ModelerUtils.allAlgs = algs
@ -61,7 +61,7 @@ class ModelerAlgorithmProvider(AlgorithmProvider):
return ModelerUtils.modelsFolder() return ModelerUtils.modelsFolder()
def getDescription(self): def getDescription(self):
return 'Models' return self.tr('Models', 'ModelerAlgorithmProvider')
def getName(self): def getName(self):
return 'model' return 'model'
@ -86,5 +86,4 @@ class ModelerAlgorithmProvider(AlgorithmProvider):
self.algs.append(alg) self.algs.append(alg)
except WrongModelException, e: except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + descriptionFile + '\n' self.tr('Could not load model %s\n%s', 'ModelerAlgorithmProvider') % (descriptionFile, e.msg))
+ e.msg)

View File

@ -166,9 +166,9 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
if hasattr(self.searchBox, 'setPlaceholderText'): if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(self.tr('Search...')) self.searchBox.setPlaceholderText(self.tr('Search...'))
if hasattr(self.textName, 'setPlaceholderText'): if hasattr(self.textName, 'setPlaceholderText'):
self.textName.setPlaceholderText('[Enter model name here]') self.textName.setPlaceholderText(self.tr('[Enter model name here]'))
if hasattr(self.textGroup, 'setPlaceholderText'): if hasattr(self.textGroup, 'setPlaceholderText'):
self.textGroup.setPlaceholderText('[Enter group name here]') self.textGroup.setPlaceholderText(self.tr('[Enter group name here]'))
# Connect signals and slots # Connect signals and slots
self.inputsTree.doubleClicked.connect(self.addInput) self.inputsTree.doubleClicked.connect(self.addInput)
@ -313,7 +313,7 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
def openModel(self): def openModel(self):
filename = unicode(QFileDialog.getOpenFileName(self, filename = unicode(QFileDialog.getOpenFileName(self,
self.tr('Open Model'), ModelerUtils.modelsFolder(), self.tr('Open Model'), ModelerUtils.modelsFolder(),
self.tr('Processing models (*.model)'))) self.tr('Processing models (*.model *.MODEL)')))
if filename: if filename:
try: try:
alg = ModelerAlgorithm.fromFile(filename) alg = ModelerAlgorithm.fromFile(filename)
@ -327,18 +327,16 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
self.hasChanged = False self.hasChanged = False
except WrongModelException, e: except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + filename + '\n' self.tr('Could not load model %s\n%s') % (filename, e.msg))
+ e.msg)
QMessageBox.critical(self, self.tr('Could not open model'), QMessageBox.critical(self, self.tr('Could not open model'),
self.tr('The selected model could not be loaded.\n' self.tr('The selected model could not be loaded.\n'
'See the log for more information.')) 'See the log for more information.'))
except Exception, e: except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + filename + '\n' self.tr('Could not load model %s\n%s') % (filename, e.args[0]))
+ e.args[0])
QMessageBox.critical(self, self.tr('Could not open model'), QMessageBox.critical(self, self.tr('Could not open model'),
self.tr('The selected model could not be loaded.\n' self.tr('The selected model could not be loaded.\n'
'See the log for more information.')) 'See the log for more information.'))
def repaintModel(self): def repaintModel(self):
self.scene = ModelerScene() self.scene = ModelerScene()
@ -483,7 +481,7 @@ class ModelerDialog(QDialog, Ui_DlgModeler):
if len(groups) > 0: if len(groups) > 0:
mainItem = QTreeWidgetItem() mainItem = QTreeWidgetItem()
mainItem.setText(0, 'Geoalgorithms') mainItem.setText(0, self.tr('Geoalgorithms'))
mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon()) mainItem.setIcon(0, GeoAlgorithm.getDefaultIcon())
mainItem.setToolTip(0, mainItem.text(0)) mainItem.setToolTip(0, mainItem.text(0))
for (groupname, group) in groups.items(): for (groupname, group) in groups.items():

View File

@ -46,7 +46,7 @@ class ModelerOnlyAlgorithmProvider(AlgorithmProvider):
return 'modelertools' return 'modelertools'
def getDescription(self): def getDescription(self):
return 'Modeler-only tools' return self.tr('Modeler-only tools', 'ModelerOnlyAlgorithmProvider')
def getIcon(self): def getIcon(self):
return QIcon(os.path.dirname(__file__) + '/../images/model.png') return QIcon(os.path.dirname(__file__) + '/../images/model.png')

View File

@ -78,7 +78,7 @@ class ModelerParameterDefinitionDialog(QDialog):
self.setupUi() self.setupUi()
def setupUi(self): def setupUi(self):
self.setWindowTitle('Parameter definition') self.setWindowTitle(self.tr('Parameter definition'))
self.verticalLayout = QVBoxLayout(self) self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setSpacing(40) self.verticalLayout.setSpacing(40)
@ -87,7 +87,7 @@ class ModelerParameterDefinitionDialog(QDialog):
self.horizontalLayout = QHBoxLayout(self) self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(2) self.horizontalLayout.setSpacing(2)
self.horizontalLayout.setMargin(0) self.horizontalLayout.setMargin(0)
self.label = QLabel('Parameter name') self.label = QLabel(self.tr('Parameter name'))
self.horizontalLayout.addWidget(self.label) self.horizontalLayout.addWidget(self.label)
self.nameTextBox = QLineEdit() self.nameTextBox = QLineEdit()
self.horizontalLayout.addWidget(self.nameTextBox) self.horizontalLayout.addWidget(self.nameTextBox)
@ -107,7 +107,7 @@ class ModelerParameterDefinitionDialog(QDialog):
== ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN \ == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN \
or isinstance(self.param, ParameterBoolean): or isinstance(self.param, ParameterBoolean):
self.state = QCheckBox() self.state = QCheckBox()
self.state.setText('Checked') self.state.setText(self.tr('Checked'))
self.state.setChecked(False) self.state.setChecked(False)
if self.param is not None: if self.param is not None:
self.state.setChecked(True if self.param.value else False) self.state.setChecked(True if self.param.value else False)
@ -116,7 +116,7 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \ == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \
or isinstance(self.param, ParameterTableField): or isinstance(self.param, ParameterTableField):
self.horizontalLayout2.addWidget(QLabel('Parent layer')) self.horizontalLayout2.addWidget(QLabel(self.tr('Parent layer')))
self.parentCombo = QComboBox() self.parentCombo = QComboBox()
idx = 0 idx = 0
for param in self.alg.inputs.values(): for param in self.alg.inputs.values():
@ -131,10 +131,10 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_RASTER \ == ModelerParameterDefinitionDialog.PARAMETER_RASTER \
or isinstance(self.param, ParameterRaster): or isinstance(self.param, ParameterRaster):
self.horizontalLayout2.addWidget(QLabel('Required')) self.horizontalLayout2.addWidget(QLabel(self.tr('Required')))
self.yesNoCombo = QComboBox() self.yesNoCombo = QComboBox()
self.yesNoCombo.addItem('Yes') self.yesNoCombo.addItem(self.tr('Yes'))
self.yesNoCombo.addItem('No') self.yesNoCombo.addItem(self.tr('No'))
if self.param is not None: if self.param is not None:
self.yesNoCombo.setCurrentIndex( self.yesNoCombo.setCurrentIndex(
(1 if self.param.optional else 0)) (1 if self.param.optional else 0))
@ -143,10 +143,10 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_TABLE \ == ModelerParameterDefinitionDialog.PARAMETER_TABLE \
or isinstance(self.param, ParameterTable): or isinstance(self.param, ParameterTable):
self.horizontalLayout2.addWidget(QLabel('Required')) self.horizontalLayout2.addWidget(QLabel(self.tr('Required')))
self.yesNoCombo = QComboBox() self.yesNoCombo = QComboBox()
self.yesNoCombo.addItem('Yes') self.yesNoCombo.addItem(self.tr('Yes'))
self.yesNoCombo.addItem('No') self.yesNoCombo.addItem(self.tr('No'))
if self.param is not None: if self.param is not None:
self.yesNoCombo.setCurrentIndex( self.yesNoCombo.setCurrentIndex(
(1 if self.param.optional else 0)) (1 if self.param.optional else 0))
@ -155,17 +155,17 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_VECTOR \ == ModelerParameterDefinitionDialog.PARAMETER_VECTOR \
or isinstance(self.param, ParameterVector): or isinstance(self.param, ParameterVector):
self.horizontalLayout2.addWidget(QLabel('Required')) self.horizontalLayout2.addWidget(QLabel(self.tr('Required')))
self.yesNoCombo = QComboBox() self.yesNoCombo = QComboBox()
self.yesNoCombo.addItem('Yes') self.yesNoCombo.addItem(self.tr('Yes'))
self.yesNoCombo.addItem('No') self.yesNoCombo.addItem(self.tr('No'))
self.horizontalLayout2.addWidget(self.yesNoCombo) self.horizontalLayout2.addWidget(self.yesNoCombo)
self.horizontalLayout3.addWidget(QLabel('Shape type')) self.horizontalLayout3.addWidget(QLabel(self.tr('Shape type')))
self.shapetypeCombo = QComboBox() self.shapetypeCombo = QComboBox()
self.shapetypeCombo.addItem('Any') self.shapetypeCombo.addItem(self.tr('Any'))
self.shapetypeCombo.addItem('Point') self.shapetypeCombo.addItem(self.tr('Point'))
self.shapetypeCombo.addItem('Line') self.shapetypeCombo.addItem(self.tr('Line'))
self.shapetypeCombo.addItem('Polygon') self.shapetypeCombo.addItem(self.tr('Polygon'))
if self.param is not None: if self.param is not None:
self.yesNoCombo.setCurrentIndex( self.yesNoCombo.setCurrentIndex(
(1 if self.param.optional else 0)) (1 if self.param.optional else 0))
@ -177,19 +177,19 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE \ == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE \
or isinstance(self.param, ParameterMultipleInput): or isinstance(self.param, ParameterMultipleInput):
self.horizontalLayout2.addWidget(QLabel('Mandatory')) self.horizontalLayout2.addWidget(QLabel(self.tr('Mandatory')))
self.yesNoCombo = QComboBox() self.yesNoCombo = QComboBox()
self.yesNoCombo.addItem('Yes') self.yesNoCombo.addItem(self.tr('Yes'))
self.yesNoCombo.addItem('No') self.yesNoCombo.addItem(self.tr('No'))
self.horizontalLayout2.addWidget(self.yesNoCombo) self.horizontalLayout2.addWidget(self.yesNoCombo)
self.horizontalLayout3.addWidget(QLabel('Data type')) self.horizontalLayout3.addWidget(QLabel(self.tr('Data type')))
self.datatypeCombo = QComboBox() self.datatypeCombo = QComboBox()
self.datatypeCombo.addItem('Vector (any)') self.datatypeCombo.addItem(self.tr('Vector (any)'))
self.datatypeCombo.addItem('Vector (point)') self.datatypeCombo.addItem(self.tr('Vector (point)'))
self.datatypeCombo.addItem('Vector (line)') self.datatypeCombo.addItem(self.tr('Vector (line)'))
self.datatypeCombo.addItem('Vector (polygon)') self.datatypeCombo.addItem(self.tr('Vector (polygon)'))
self.datatypeCombo.addItem('Raster') self.datatypeCombo.addItem(self.tr('Raster'))
self.datatypeCombo.addItem('Table') self.datatypeCombo.addItem(self.tr('Table'))
if self.param is not None: if self.param is not None:
self.yesNoCombo.setCurrentIndex( self.yesNoCombo.setCurrentIndex(
(1 if self.param.optional else 0)) (1 if self.param.optional else 0))
@ -200,15 +200,15 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_NUMBER \ == ModelerParameterDefinitionDialog.PARAMETER_NUMBER \
or isinstance(self.param, ParameterNumber): or isinstance(self.param, ParameterNumber):
self.horizontalLayout2.addWidget(QLabel('Min/Max values')) self.horizontalLayout2.addWidget(QLabel(self.tr('Min/Max values')))
self.minTextBox = QLineEdit() self.minTextBox = QLineEdit()
self.maxTextBox = QLineEdit() self.maxTextBox = QLineEdit()
self.horizontalLayout2.addWidget(self.minTextBox) self.horizontalLayout2.addWidget(self.minTextBox)
self.horizontalLayout2.addWidget(self.maxTextBox) self.horizontalLayout2.addWidget(self.maxTextBox)
self.verticalLayout.addLayout(self.horizontalLayout2) self.verticalLayout.addLayout(self.horizontalLayout2)
self.horizontalLayout3.addWidget(QLabel('Default value')) self.horizontalLayout3.addWidget(QLabel(self.tr('Default value')))
self.defaultTextBox = QLineEdit() self.defaultTextBox = QLineEdit()
self.defaultTextBox.setText('0') self.defaultTextBox.setText(self.tr('0'))
if self.param is not None: if self.param is not None:
self.defaultTextBox.setText(str(self.param.default)) self.defaultTextBox.setText(str(self.param.default))
self.horizontalLayout3.addWidget(self.defaultTextBox) self.horizontalLayout3.addWidget(self.defaultTextBox)
@ -216,7 +216,7 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_STRING \ == ModelerParameterDefinitionDialog.PARAMETER_STRING \
or isinstance(self.param, ParameterString): or isinstance(self.param, ParameterString):
self.horizontalLayout2.addWidget(QLabel('Default value')) self.horizontalLayout2.addWidget(QLabel(self.tr('Default value')))
self.defaultTextBox = QLineEdit() self.defaultTextBox = QLineEdit()
if self.param is not None: if self.param is not None:
self.defaultTextBox.setText(self.param.default) self.defaultTextBox.setText(self.param.default)
@ -225,10 +225,10 @@ class ModelerParameterDefinitionDialog(QDialog):
elif self.paramType == \ elif self.paramType == \
ModelerParameterDefinitionDialog.PARAMETER_FILE \ ModelerParameterDefinitionDialog.PARAMETER_FILE \
or isinstance(self.param, ParameterFile): or isinstance(self.param, ParameterFile):
self.horizontalLayout2.addWidget(QLabel('Type')) self.horizontalLayout2.addWidget(QLabel(self.tr('Type')))
self.fileFolderCombo = QComboBox() self.fileFolderCombo = QComboBox()
self.fileFolderCombo.addItem('File') self.fileFolderCombo.addItem(self.tr('File'))
self.fileFolderCombo.addItem('Folder') self.fileFolderCombo.addItem(self.tr('Folder'))
if self.param is not None: if self.param is not None:
self.fileFolderCombo.setCurrentIndex( self.fileFolderCombo.setCurrentIndex(
(1 if self.param.isFolder else 0)) (1 if self.param.isFolder else 0))
@ -250,8 +250,8 @@ class ModelerParameterDefinitionDialog(QDialog):
def okPressed(self): def okPressed(self):
description = unicode(self.nameTextBox.text()) description = unicode(self.nameTextBox.text())
if description.strip() == '': if description.strip() == '':
QMessageBox.warning(self, 'Unable to define parameter', QMessageBox.warning(self, self.tr('Unable to define parameter'),
'Invalid parameter name') self.tr('Invalid parameter name'))
return return
if self.param is None: if self.param is None:
validChars = \ validChars = \
@ -270,8 +270,8 @@ class ModelerParameterDefinitionDialog(QDialog):
== ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \ == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD \
or isinstance(self.param, ParameterTableField): or isinstance(self.param, ParameterTableField):
if self.parentCombo.currentIndex() < 0: if self.parentCombo.currentIndex() < 0:
QMessageBox.warning(self, 'Unable to define parameter', QMessageBox.warning(self, self.tr('Unable to define parameter'),
'Wrong or missing parameter values') self.tr('Wrong or missing parameter values'))
return return
parent = self.parentCombo.itemData(self.parentCombo.currentIndex()) parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
self.param = ParameterTableField(name, description, parent) self.param = ParameterTableField(name, description, parent)
@ -314,8 +314,8 @@ class ModelerParameterDefinitionDialog(QDialog):
self.param = ParameterNumber(name, description, vmin, vmax, self.param = ParameterNumber(name, description, vmin, vmax,
float(str(self.defaultTextBox.text()))) float(str(self.defaultTextBox.text())))
except: except:
QMessageBox.warning(self, 'Unable to define parameter', QMessageBox.warning(self, self.tr('Unable to define parameter'),
'Wrong or missing parameter values') self.tr('Wrong or missing parameter values'))
return return
elif self.paramType \ elif self.paramType \
== ModelerParameterDefinitionDialog.PARAMETER_STRING \ == ModelerParameterDefinitionDialog.PARAMETER_STRING \

View File

@ -82,7 +82,7 @@ class ModelerParametersDialog(QDialog):
hLayout = QHBoxLayout() hLayout = QHBoxLayout()
hLayout.setSpacing(5) hLayout.setSpacing(5)
hLayout.setMargin(0) hLayout.setMargin(0)
descriptionLabel = QLabel("Description") descriptionLabel = QLabel(self.tr("Description"))
self.descriptionBox = QLineEdit() self.descriptionBox = QLineEdit()
self.descriptionBox.setText(self._alg.name) self.descriptionBox.setText(self._alg.name)
hLayout.addWidget(descriptionLabel) hLayout.addWidget(descriptionLabel)
@ -96,7 +96,7 @@ class ModelerParametersDialog(QDialog):
for param in self._alg.parameters: for param in self._alg.parameters:
if param.isAdvanced: if param.isAdvanced:
self.advancedButton = QPushButton() self.advancedButton = QPushButton()
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
self.advancedButton.setMaximumWidth(150) self.advancedButton.setMaximumWidth(150)
self.advancedButton.clicked.connect( self.advancedButton.clicked.connect(
self.showAdvancedParametersClicked) self.showAdvancedParametersClicked)
@ -141,7 +141,7 @@ class ModelerParametersDialog(QDialog):
label = QLabel(' ') label = QLabel(' ')
self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(label)
label = QLabel('Parent algorithms') label = QLabel(self.tr('Parent algorithms'))
self.dependenciesPanel = self.getDependenciesPanel() self.dependenciesPanel = self.getDependenciesPanel()
self.verticalLayout.addWidget(label) self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(self.dependenciesPanel) self.verticalLayout.addWidget(self.dependenciesPanel)
@ -161,7 +161,7 @@ class ModelerParametersDialog(QDialog):
self.scrollArea = QScrollArea() self.scrollArea = QScrollArea()
self.scrollArea.setWidget(self.paramPanel) self.scrollArea.setWidget(self.paramPanel)
self.scrollArea.setWidgetResizable(True) self.scrollArea.setWidgetResizable(True)
self.tabWidget.addTab(self.scrollArea, 'Parameters') self.tabWidget.addTab(self.scrollArea, self.tr('Parameters'))
self.webView = QWebView() self.webView = QWebView()
html = None html = None
@ -173,15 +173,15 @@ class ModelerParametersDialog(QDialog):
else: else:
url = QUrl(help) url = QUrl(help)
else: else:
html = '<h2>Sorry, no help is available for this \ html = self.tr('<h2>Sorry, no help is available for this '
algorithm.</h2>' 'algorithm.</h2>')
try: try:
if html: if html:
self.webView.setHtml(html) self.webView.setHtml(html)
elif url: elif url:
self.webView.load(url) self.webView.load(url)
except: 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.tabWidget.addTab(self.webView, 'Help')
self.verticalLayout2.addWidget(self.tabWidget) self.verticalLayout2.addWidget(self.tabWidget)
self.verticalLayout2.addWidget(self.buttonBox) self.verticalLayout2.addWidget(self.buttonBox)
@ -207,9 +207,9 @@ class ModelerParametersDialog(QDialog):
def showAdvancedParametersClicked(self): def showAdvancedParametersClicked(self):
self.showAdvanced = not self.showAdvanced self.showAdvanced = not self.showAdvanced
if self.showAdvanced: if self.showAdvanced:
self.advancedButton.setText('Hide advanced parameters') self.advancedButton.setText(self.tr('Hide advanced parameters'))
else: else:
self.advancedButton.setText('Show advanced parameters') self.advancedButton.setText(self.tr('Show advanced parameters'))
for param in self._alg.parameters: for param in self._alg.parameters:
if param.isAdvanced: if param.isAdvanced:
self.labels[param.name].setVisible(self.showAdvanced) self.labels[param.name].setVisible(self.showAdvanced)
@ -241,7 +241,7 @@ class ModelerParametersDialog(QDialog):
return self.model.inputs[value.name].param.description return self.model.inputs[value.name].param.description
else: else:
alg = self.model.algs[value.alg] alg = self.model.algs[value.alg]
return "'%s' from algorithm '%s'" % (alg.algorithm.getOutputFromName(value.output).description, alg.description) return self.tr("'%s' from algorithm '%s'") % (alg.algorithm.getOutputFromName(value.output).description, alg.description)
def getWidgetFromParameter(self, param): def getWidgetFromParameter(self, param):
@ -628,8 +628,8 @@ class ModelerParametersDialog(QDialog):
if self.alg is not None: if self.alg is not None:
self.close() self.close()
else: else:
QMessageBox.warning(self, 'Unable to add algorithm', QMessageBox.warning(self, self.tr('Unable to add algorithm'),
'Wrong or missing parameter values') self.tr('Wrong or missing parameter values'))
def cancelPressed(self): def cancelPressed(self):
self.alg = None self.alg = None

View File

@ -139,6 +139,3 @@ class ModelerScene(QtGui.QGraphicsScene):
if mouseEvent.button() != QtCore.Qt.LeftButton: if mouseEvent.button() != QtCore.Qt.LeftButton:
return return
super(ModelerScene, self).mousePressEvent(mouseEvent) super(ModelerScene, self).mousePressEvent(mouseEvent)

View File

@ -39,7 +39,7 @@ class MultilineTextPanel(QtGui.QWidget):
self.verticalLayout.setSpacing(2) self.verticalLayout.setSpacing(2)
self.verticalLayout.setMargin(0) self.verticalLayout.setMargin(0)
self.combo = QtGui.QComboBox() self.combo = QtGui.QComboBox()
self.combo.addItem('[Use text below]') self.combo.addItem(self.tr('[Use text below]'))
for option in options: for option in options:
self.combo.addItem(option[0], option[1]) self.combo.addItem(option[0], option[1])
self.combo.setSizePolicy(QtGui.QSizePolicy.Expanding, self.combo.setSizePolicy(QtGui.QSizePolicy.Expanding,

View File

@ -43,14 +43,14 @@ class RasterLayerBoundsAlgorithm(GeoAlgorithm):
def defineCharacteristics(self): def defineCharacteristics(self):
self.showInModeler = True self.showInModeler = True
self.showInToolbox = False self.showInToolbox = False
self.name = 'Raster layer bounds' self.name = self.tr('Raster layer bounds', 'RasterLayerBoundsAlgorithm')
self.group = 'Modeler-only tools' self.group = self.tr('Modeler-only tools', 'RasterLayerBoundsAlgorithm')
self.addParameter(ParameterRaster(self.LAYER, 'Layer')) self.addParameter(ParameterRaster(self.LAYER, self.tr('Layer', 'RasterLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.XMIN, 'min X')) self.addOutput(OutputNumber(self.XMIN, self.tr('min X', 'RasterLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.XMAX, 'max X')) self.addOutput(OutputNumber(self.XMAX, self.tr('max X', 'RasterLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.YMIN, 'min Y')) self.addOutput(OutputNumber(self.YMIN, self.tr('min Y', 'RasterLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.YMAX, 'max Y')) self.addOutput(OutputNumber(self.YMAX, self.tr('max Y', 'RasterLayerBoundsAlgorithm')))
self.addOutput(OutputExtent(self.EXTENT, 'Extent')) self.addOutput(OutputExtent(self.EXTENT, self.tr('Extent', 'RasterLayerBoundsAlgorithm')))
def processAlgorithm(self, progress): def processAlgorithm(self, progress):
uri = self.getParameterValue(self.LAYER) uri = self.getParameterValue(self.LAYER)
@ -63,4 +63,3 @@ class RasterLayerBoundsAlgorithm(GeoAlgorithm):
layer.extent().xMaximum(), layer.extent().xMaximum(),
layer.extent().yMinimum(), layer.extent().yMinimum(),
layer.extent().yMaximum())) layer.extent().yMaximum()))

View File

@ -44,14 +44,14 @@ class VectorLayerBoundsAlgorithm(GeoAlgorithm):
def defineCharacteristics(self): def defineCharacteristics(self):
self.showInModeler = True self.showInModeler = True
self.showInToolbox = False self.showInToolbox = False
self.name = 'Vector layer bounds' self.name = self.tr('Vector layer bounds', 'VectorLayerBoundsAlgorithm')
self.group = 'Modeler-only tools' self.group = self.tr('Modeler-only tools', 'VectorLayerBoundsAlgorithm')
self.addParameter(ParameterVector(self.LAYER, 'Layer')) self.addParameter(ParameterVector(self.LAYER, self.tr('Layer', 'VectorLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.XMIN, 'min X')) self.addOutput(OutputNumber(self.XMIN, self.tr('min X', 'VectorLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.XMAX, 'max X')) self.addOutput(OutputNumber(self.XMAX, self.tr('max X', 'VectorLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.YMIN, 'min Y')) self.addOutput(OutputNumber(self.YMIN, self.tr('min Y', 'VectorLayerBoundsAlgorithm')))
self.addOutput(OutputNumber(self.YMAX, 'max Y')) self.addOutput(OutputNumber(self.YMAX, self.tr('max Y', 'VectorLayerBoundsAlgorithm')))
self.addOutput(OutputExtent(self.EXTENT, 'Extent')) self.addOutput(OutputExtent(self.EXTENT, self.tr('Extent', 'VectorLayerBoundsAlgorithm')))
def processAlgorithm(self, progress): def processAlgorithm(self, progress):
uri = self.getParameterValue(self.LAYER) uri = self.getParameterValue(self.LAYER)

View File

@ -35,22 +35,25 @@ from processing.script.ScriptUtils import ScriptUtils
class AddScriptFromFileAction(ToolboxAction): class AddScriptFromFileAction(ToolboxAction):
def __init__(self): def __init__(self):
self.name = "Add script from file" self.name = self.tr('Add script from file', 'AddScriptFromFileAction')
self.group = 'Tools' self.group = self.tr('Tools', 'AddScriptFromFileAction')
def getIcon(self): def getIcon(self):
return QtGui.QIcon(':/processing/images/script.png') return QtGui.QIcon(':/processing/images/script.png')
def execute(self): def execute(self):
filename = QtGui.QFileDialog.getOpenFileName(self.toolbox, 'Script files', None, filename = QtGui.QFileDialog.getOpenFileName(self.toolbox,
'*.py') self.tr('Script files', 'AddScriptFromFileAction'), None,
self.tr('Script files (*.py *.PY)', 'AddScriptFromFileAction'))
if filename: if filename:
try: try:
script = ScriptAlgorithm(filename) script = ScriptAlgorithm(filename)
except WrongScriptException: except WrongScriptException:
QtGui.QMessageBox.warning(self.toolbox, "Error reading script", "The selected file does not contain a valid script") QtGui.QMessageBox.warning(self.toolbox,
self.tr('Error reading script', 'AddScriptFromFileAction'),
self.tr('The selected file does not contain a valid script', 'AddScriptFromFileAction'))
return return
destFilename = os.path.join(ScriptUtils.scriptsFolder(), os.path.basename(filename)) destFilename = os.path.join(ScriptUtils.scriptsFolder(), os.path.basename(filename))
with open(destFilename, "w") as f: with open(destFilename, 'w') as f:
f.write(script.script) f.write(script.script)
self.toolbox.updateProvider('script') self.toolbox.updateProvider('script')

View File

@ -87,7 +87,7 @@ class ScriptAlgorithm(GeoAlgorithm):
self.silentOutputs = [] self.silentOutputs = []
filename = os.path.basename(self.descriptionFile) filename = os.path.basename(self.descriptionFile)
self.name = filename[:filename.rfind('.')].replace('_', ' ') self.name = filename[:filename.rfind('.')].replace('_', ' ')
self.group = 'User scripts' self.group = self.tr('User scripts', 'ScriptAlgorithm')
lines = open(self.descriptionFile) lines = open(self.descriptionFile)
line = lines.readline() line = lines.readline()
while line != '': while line != '':
@ -95,21 +95,21 @@ class ScriptAlgorithm(GeoAlgorithm):
try: try:
self.processParameterLine(line.strip('\n')) self.processParameterLine(line.strip('\n'))
except: except:
raise WrongScriptException('Could not load script: ' raise WrongScriptException(
+ self.descriptionFile + '\n' self.tr('Could not load script: %s\n'
+ 'Problem with line: ' + line) 'Problem with line: %d', 'ScriptAlgorithm') % (self.descriptionFile, line))
self.script += line self.script += line
line = lines.readline() line = lines.readline()
lines.close() lines.close()
if self.group == '[Test scripts]': if self.group == self.tr('[Test scripts]', 'ScriptAlgorithm'):
self.showInModeler = False self.showInModeler = False
self.showInToolbox = False self.showInToolbox = False
def defineCharacteristicsFromScript(self): def defineCharacteristicsFromScript(self):
lines = self.script.split('\n') lines = self.script.split('\n')
self.silentOutputs = [] self.silentOutputs = []
self.name = '[Unnamed algorithm]' self.name = self.tr('[Unnamed algorithm]', 'ScriptAlgorithm')
self.group = 'User scripts' self.group = self.tr('User scripts', 'ScriptAlgorithm')
for line in lines: for line in lines:
if line.startswith('##'): if line.startswith('##'):
try: try:
@ -228,10 +228,9 @@ class ScriptAlgorithm(GeoAlgorithm):
out.description = desc out.description = desc
self.addOutput(out) self.addOutput(out)
else: else:
raise WrongScriptException('Could not load script:' raise WrongScriptException(
+ self.descriptionFile or '' self.tr('Could not load script: %s.\n'
+ '.\n Problem with line "' + line + '"' 'Problem with line %d', 'ScriptAlgorithm') % (self.descriptionFile or '', line))
)
def processDescriptionParameterLine(self, line): def processDescriptionParameterLine(self, line):
try: try:
@ -244,10 +243,9 @@ class ScriptAlgorithm(GeoAlgorithm):
else: else:
self.addOutput(getOutputFromString(line)) self.addOutput(getOutputFromString(line))
except Exception: except Exception:
raise WrongScriptException('Could not load script:' raise WrongScriptException(
+ self.descriptionFile or '' self.tr('Could not load script: %s.\n'
+ '.\n Problem with line "' + line + '"' 'Problem with line %d', 'ScriptAlgorithm') % (self.descriptionFile or '', line))
)
def processAlgorithm(self, progress): def processAlgorithm(self, progress):

View File

@ -42,7 +42,7 @@ class ScriptAlgorithmProvider(AlgorithmProvider):
def __init__(self): def __init__(self):
AlgorithmProvider.__init__(self) AlgorithmProvider.__init__(self)
self.actions.extend([CreateNewScriptAction('Create new script', self.actions.extend([CreateNewScriptAction(self.tr('Create new script', 'ScriptAlgorithmProvider'),
CreateNewScriptAction.SCRIPT_PYTHON), CreateNewScriptAction.SCRIPT_PYTHON),
AddScriptFromFileAction(), AddScriptFromFileAction(),
GetScriptsAction()]) GetScriptsAction()])
@ -54,7 +54,7 @@ class ScriptAlgorithmProvider(AlgorithmProvider):
AlgorithmProvider.initializeSettings(self) AlgorithmProvider.initializeSettings(self)
ProcessingConfig.addSetting(Setting(self.getDescription(), ProcessingConfig.addSetting(Setting(self.getDescription(),
ScriptUtils.SCRIPTS_FOLDER, ScriptUtils.SCRIPTS_FOLDER,
'Scripts folder', self.tr('Scripts folder', 'ScriptAlgorithmProvider'),
ScriptUtils.scriptsFolder())) ScriptUtils.scriptsFolder()))
def unload(self): def unload(self):
@ -68,10 +68,8 @@ class ScriptAlgorithmProvider(AlgorithmProvider):
return 'script' return 'script'
def getDescription(self): def getDescription(self):
return 'Scripts' return self.tr('Scripts', 'ScriptAlgorithmProvider')
def _loadAlgorithms(self): def _loadAlgorithms(self):
folder = ScriptUtils.scriptsFolder() folder = ScriptUtils.scriptsFolder()
self.algs = ScriptUtils.loadFromFolder(folder) self.algs = ScriptUtils.loadFromFolder(folder)