diff --git a/python/console/console.py b/python/console/console.py
index a9ada9cdf05..02d4fd35a2d 100644
--- a/python/console/console.py
+++ b/python/console/console.py
@@ -464,19 +464,18 @@ class PythonConsoleWidget(QWidget):
self.layoutFind = QGridLayout(self.widgetFind)
self.layoutFind.setContentsMargins(0, 0, 0, 0)
self.lineEditFind = QgsFilterLineEdit()
- self.lineEditFind.setPlaceholderText('Enter text to find...')
+ placeHolderTxt = QCoreApplication.translate("PythonConsole", "Enter text to find...")
+ self.lineEditFind.setPlaceholderText(placeHolderTxt)
self.findNextButton = QToolButton()
self.findNextButton.setEnabled(False)
- toolTipfindNext = QCoreApplication.translate("PythonConsole",
- "Find Next")
+ toolTipfindNext = QCoreApplication.translate("PythonConsole", "Find Next")
self.findNextButton.setToolTip(toolTipfindNext)
self.findNextButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchNextEditorConsole.png"))
self.findNextButton.setIconSize(QSize(24, 24))
self.findNextButton.setAutoRaise(True)
self.findPrevButton = QToolButton()
self.findPrevButton.setEnabled(False)
- toolTipfindPrev = QCoreApplication.translate("PythonConsole",
- "Find Previous")
+ toolTipfindPrev = QCoreApplication.translate("PythonConsole", "Find Previous")
self.findPrevButton.setToolTip(toolTipfindPrev)
self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png"))
self.findPrevButton.setIconSize(QSize(24, 24))
@@ -628,8 +627,9 @@ class PythonConsoleWidget(QWidget):
def openScriptFile(self):
settings = QSettings()
lastDirPath = settings.value("pythonConsole/lastDirPath").toString()
+ openFileTr = QCoreApplication.translate("PythonConsole", "Open File")
filename = QFileDialog.getOpenFileName(
- self, "Open File", lastDirPath, "Script file (*.py)")
+ self, openFileTr, lastDirPath, "Script file (*.py)")
if not filename.isEmpty():
for i in range(self.tabEditorWidget.count()):
tabWidget = self.tabEditorWidget.widget(i)
@@ -650,15 +650,18 @@ class PythonConsoleWidget(QWidget):
try:
tabWidget.save()
except (IOError, OSError), e:
- QMessageBox.warning(self, "Save Error",
- "Failed to save %s: %s" % (tabWidget.path, e))
+ errTr = QCoreApplication.translate("PythonConsole", "Save Error")
+ msgErrTr = QCoreApplication.translate("PythonConsole",
+ "Failed to save %1: %2").arg(tabWidget.path, e)
+ QMessageBox.warning(self, errTr, msgErrTr)
def saveAsScriptFile(self):
tabWidget = self.tabEditorWidget.currentWidget()
if tabWidget is None:
return
+ saveAsFileTr = QCoreApplication.translate("PythonConsole", "Save File As")
filename = QFileDialog.getSaveFileName(self,
- "Save File As",
+ saveAsFileTr,
tabWidget.path, "Script file (*.py)")
if not filename.isEmpty():
#print tabWidget.path
diff --git a/python/console/console_editor.py b/python/console/console_editor.py
index 00e0ea973bb..f41433ccd78 100644
--- a/python/console/console_editor.py
+++ b/python/console/console_editor.py
@@ -472,23 +472,30 @@ class Editor(QsciScintilla):
pass
else:
raise e
+ tmpFileTr = QCoreApplication.translate('PythonConsole', ' [Temporary file saved in ')
if tmp:
- name = name + ' [Temporary file saved in ' + dir + ']'
+ name = name + tmpFileTr + dir + ']'
if _traceback:
+ msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: %1').arg(name)
print "## %s" % datetime.datetime.now()
- print "## Script error: %s" % name
+ print msgTraceTr
sys.stderr.write(_traceback)
p.stderr.close()
else:
+ msgSuccessTr = QCoreApplication.translate('PythonConsole',
+ '## Script executed successfully: %1').arg(name)
print "## %s" % datetime.datetime.now()
- print "## Script executed successfully: %s" % name
+ print msgSuccessTr
sys.stdout.write(out)
p.stdout.close()
del p
if tmp:
os.remove(filename)
except IOError, error:
- print 'Cannot execute file %s. Error: %s' % (filename, error.strerror)
+ IOErrorTr = QCoreApplication.translate('PythonConsole',
+ 'Cannot execute file %1. Error: %2') \
+ .arg(filename, error.strerror)
+ print IOErrorTr
except:
s = traceback.format_exc()
print '## Error: '
@@ -535,7 +542,8 @@ class Editor(QsciScintilla):
def goToLine(self, objName, linenr):
self.SendScintilla(QsciScintilla.SCI_GOTOLINE, linenr-1)
- self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
+ self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART,
+ self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
self.SendScintilla(QsciScintilla.SCI_SETTARGETEND, len(self.text()))
pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET, len(objName), objName)
index = pos - self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
@@ -557,7 +565,10 @@ class Editor(QsciScintilla):
try:
file = open(pathfile, "r").readlines()
except IOError, error:
- print 'The file %s could not be opened. Error: %s' % (pathfile, error.strerror)
+ IOErrorTr = QCoreApplication.translate('PythonConsole',
+ 'The file %1 could not be opened. Error: %2') \
+ .arg(pathfile, error.strerro)
+ print IOErrorTr
for line in reversed(file):
self.insert(line)
QApplication.restoreOverrideCursor()
@@ -566,7 +577,9 @@ class Editor(QsciScintilla):
self.parent.tw.listObject(self.parent.tw.currentWidget())
self.mtime = os.stat(pathfile).st_mtime
- msgText = QCoreApplication.translate('PythonConsole', 'The file "%1" has been changed and reloaded').arg(pathfile)
+ msgText = QCoreApplication.translate('PythonConsole',
+ 'The file "%1" has been changed and reloaded') \
+ .arg(pathfile)
self.parent.pc.callWidgetMessageBarEditor(msgText, 1, False)
QsciScintilla.focusInEvent(self, e)
@@ -609,7 +622,10 @@ class EditorTab(QWidget):
try:
fn = open(unicode(filename), "rb")
except IOError, error:
- print 'The file %s could not be opened. Error: %s' % (filename, error.strerror)
+ IOErrorTr = QCoreApplication.translate('PythonConsole',
+ 'The file %1 could not be opened. Error: %2') \
+ .arg(filename, error.strerror)
+ print IOErrorTr
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
txt = fn.read()
fn.close()
@@ -621,8 +637,10 @@ class EditorTab(QWidget):
def save(self):
if self.path is None:
+ saveTr = QCoreApplication.translate('PythonConsole',
+ 'Python Console: Save file')
self.path = str(QFileDialog().getSaveFileName(self,
- "Python Console: Save file",
+ saveTr,
"*.py",
"Script file (*.py)"))
# If the user didn't select a file, abort the save operation
@@ -743,7 +761,9 @@ class EditorTabWidget(QTabWidget):
self.connect(self.fileTabMenu, SIGNAL("triggered(QAction*)"),
self.showFileTabMenuTriggered)
self.fileTabButton = QToolButton()
- self.fileTabButton.setToolTip('List all tabs')
+ txtToolTipMenuFile = QCoreApplication.translate("PythonConsole",
+ "List all tabs")
+ self.fileTabButton.setToolTip(txtToolTipMenuFile)
self.fileTabButton.setIcon(QgsApplication.getThemeIcon("console/iconFileTabsMenuConsole.png"))
self.fileTabButton.setIconSize(QSize(24, 24))
self.fileTabButton.setAutoRaise(True)
@@ -756,7 +776,9 @@ class EditorTabWidget(QTabWidget):
# Open button
self.newTabButton = QToolButton()
- self.newTabButton.setToolTip('New Tab')
+ txtToolTipNewTab = QCoreApplication.translate("PythonConsole",
+ "New Tab")
+ self.newTabButton.setToolTip(txtToolTipNewTab)
self.newTabButton.setAutoRaise(True)
self.newTabButton.setIcon(QgsApplication.getThemeIcon("console/iconNewTabEditorConsole.png"))
self.newTabButton.setIconSize(QSize(24, 24))
@@ -813,10 +835,13 @@ class EditorTabWidget(QTabWidget):
if tab2index:
tab = self.indexOf(tab)
if self.widget(tab).newEditor.isModified():
- res = QMessageBox.question( self, 'Python Console: Save File',
- 'The file "%s" has been modified, save changes ?'
- % self.tabText(tab),
- QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
+ txtSaveOnRemove = QCoreApplication.translate("PythonConsole",
+ "Python Console: Save File")
+ txtMsgSaveOnRemove = QCoreApplication.translate("PythonConsole",
+ "The file '%1' has been modified, save changes ?").arg(self.tabText(tab))
+ res = QMessageBox.question( self, txtSaveOnRemove,
+ txtMsgSaveOnRemove,
+ QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
if res == QMessageBox.Save:
self.widget(tab).save()
elif res == QMessageBox.Cancel:
@@ -856,8 +881,11 @@ class EditorTabWidget(QTabWidget):
tabName = pathFile.split('/')[-1]
self.newTabEditor(tabName, pathFile)
else:
+ errOnRestore = QCoreApplication.translate("PythonConsole",
+ "Unable to restore the file: \n%1\n") \
+ .arg(pathFile)
print '## Error: '
- s = 'Unable to restore the file: \n%s\n' % pathFile
+ s = errOnRestore
sys.stderr.write(s)
self.parent.updateTabListScript(pathFile)
if self.count() < 1: