Skip to content

Commit d3f9dd5

Browse files
committedMay 4, 2013
[pyqgis-console] fixes translation strings
1 parent fb91f76 commit d3f9dd5

File tree

2 files changed

+56
-25
lines changed

2 files changed

+56
-25
lines changed
 

‎python/console/console.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,18 @@ def __init__(self, parent=None):
464464
self.layoutFind = QGridLayout(self.widgetFind)
465465
self.layoutFind.setContentsMargins(0, 0, 0, 0)
466466
self.lineEditFind = QgsFilterLineEdit()
467-
self.lineEditFind.setPlaceholderText('Enter text to find...')
467+
placeHolderTxt = QCoreApplication.translate("PythonConsole", "Enter text to find...")
468+
self.lineEditFind.setPlaceholderText(placeHolderTxt)
468469
self.findNextButton = QToolButton()
469470
self.findNextButton.setEnabled(False)
470-
toolTipfindNext = QCoreApplication.translate("PythonConsole",
471-
"Find Next")
471+
toolTipfindNext = QCoreApplication.translate("PythonConsole", "Find Next")
472472
self.findNextButton.setToolTip(toolTipfindNext)
473473
self.findNextButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchNextEditorConsole.png"))
474474
self.findNextButton.setIconSize(QSize(24, 24))
475475
self.findNextButton.setAutoRaise(True)
476476
self.findPrevButton = QToolButton()
477477
self.findPrevButton.setEnabled(False)
478-
toolTipfindPrev = QCoreApplication.translate("PythonConsole",
479-
"Find Previous")
478+
toolTipfindPrev = QCoreApplication.translate("PythonConsole", "Find Previous")
480479
self.findPrevButton.setToolTip(toolTipfindPrev)
481480
self.findPrevButton.setIcon(QgsApplication.getThemeIcon("console/iconSearchPrevEditorConsole.png"))
482481
self.findPrevButton.setIconSize(QSize(24, 24))
@@ -628,8 +627,9 @@ def uncommentCode(self):
628627
def openScriptFile(self):
629628
settings = QSettings()
630629
lastDirPath = settings.value("pythonConsole/lastDirPath").toString()
630+
openFileTr = QCoreApplication.translate("PythonConsole", "Open File")
631631
filename = QFileDialog.getOpenFileName(
632-
self, "Open File", lastDirPath, "Script file (*.py)")
632+
self, openFileTr, lastDirPath, "Script file (*.py)")
633633
if not filename.isEmpty():
634634
for i in range(self.tabEditorWidget.count()):
635635
tabWidget = self.tabEditorWidget.widget(i)
@@ -650,15 +650,18 @@ def saveScriptFile(self):
650650
try:
651651
tabWidget.save()
652652
except (IOError, OSError), e:
653-
QMessageBox.warning(self, "Save Error",
654-
"Failed to save %s: %s" % (tabWidget.path, e))
653+
errTr = QCoreApplication.translate("PythonConsole", "Save Error")
654+
msgErrTr = QCoreApplication.translate("PythonConsole",
655+
"Failed to save %1: %2").arg(tabWidget.path, e)
656+
QMessageBox.warning(self, errTr, msgErrTr)
655657

656658
def saveAsScriptFile(self):
657659
tabWidget = self.tabEditorWidget.currentWidget()
658660
if tabWidget is None:
659661
return
662+
saveAsFileTr = QCoreApplication.translate("PythonConsole", "Save File As")
660663
filename = QFileDialog.getSaveFileName(self,
661-
"Save File As",
664+
saveAsFileTr,
662665
tabWidget.path, "Script file (*.py)")
663666
if not filename.isEmpty():
664667
#print tabWidget.path

‎python/console/console_editor.py

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -472,23 +472,30 @@ def _runSubProcess(self, filename, tmp=False):
472472
pass
473473
else:
474474
raise e
475+
tmpFileTr = QCoreApplication.translate('PythonConsole', ' [Temporary file saved in ')
475476
if tmp:
476-
name = name + ' [Temporary file saved in ' + dir + ']'
477+
name = name + tmpFileTr + dir + ']'
477478
if _traceback:
479+
msgTraceTr = QCoreApplication.translate('PythonConsole', '## Script error: %1').arg(name)
478480
print "## %s" % datetime.datetime.now()
479-
print "## Script error: %s" % name
481+
print msgTraceTr
480482
sys.stderr.write(_traceback)
481483
p.stderr.close()
482484
else:
485+
msgSuccessTr = QCoreApplication.translate('PythonConsole',
486+
'## Script executed successfully: %1').arg(name)
483487
print "## %s" % datetime.datetime.now()
484-
print "## Script executed successfully: %s" % name
488+
print msgSuccessTr
485489
sys.stdout.write(out)
486490
p.stdout.close()
487491
del p
488492
if tmp:
489493
os.remove(filename)
490494
except IOError, error:
491-
print 'Cannot execute file %s. Error: %s' % (filename, error.strerror)
495+
IOErrorTr = QCoreApplication.translate('PythonConsole',
496+
'Cannot execute file %1. Error: %2') \
497+
.arg(filename, error.strerror)
498+
print IOErrorTr
492499
except:
493500
s = traceback.format_exc()
494501
print '## Error: '
@@ -535,7 +542,8 @@ def getTextFromEditor(self):
535542

536543
def goToLine(self, objName, linenr):
537544
self.SendScintilla(QsciScintilla.SCI_GOTOLINE, linenr-1)
538-
self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART, self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
545+
self.SendScintilla(QsciScintilla.SCI_SETTARGETSTART,
546+
self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS))
539547
self.SendScintilla(QsciScintilla.SCI_SETTARGETEND, len(self.text()))
540548
pos = self.SendScintilla(QsciScintilla.SCI_SEARCHINTARGET, len(objName), objName)
541549
index = pos - self.SendScintilla(QsciScintilla.SCI_GETCURRENTPOS)
@@ -557,7 +565,10 @@ def focusInEvent(self, e):
557565
try:
558566
file = open(pathfile, "r").readlines()
559567
except IOError, error:
560-
print 'The file %s could not be opened. Error: %s' % (pathfile, error.strerror)
568+
IOErrorTr = QCoreApplication.translate('PythonConsole',
569+
'The file %1 could not be opened. Error: %2') \
570+
.arg(pathfile, error.strerro)
571+
print IOErrorTr
561572
for line in reversed(file):
562573
self.insert(line)
563574
QApplication.restoreOverrideCursor()
@@ -566,7 +577,9 @@ def focusInEvent(self, e):
566577

567578
self.parent.tw.listObject(self.parent.tw.currentWidget())
568579
self.mtime = os.stat(pathfile).st_mtime
569-
msgText = QCoreApplication.translate('PythonConsole', 'The file <b>"%1"</b> has been changed and reloaded').arg(pathfile)
580+
msgText = QCoreApplication.translate('PythonConsole',
581+
'The file <b>"%1"</b> has been changed and reloaded') \
582+
.arg(pathfile)
570583
self.parent.pc.callWidgetMessageBarEditor(msgText, 1, False)
571584

572585
QsciScintilla.focusInEvent(self, e)
@@ -609,7 +622,10 @@ def loadFile(self, filename, modified):
609622
try:
610623
fn = open(unicode(filename), "rb")
611624
except IOError, error:
612-
print 'The file <b>%s</b> could not be opened. Error: %s' % (filename, error.strerror)
625+
IOErrorTr = QCoreApplication.translate('PythonConsole',
626+
'The file <b>%1</b> could not be opened. Error: %2') \
627+
.arg(filename, error.strerror)
628+
print IOErrorTr
613629
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
614630
txt = fn.read()
615631
fn.close()
@@ -621,8 +637,10 @@ def loadFile(self, filename, modified):
621637

622638
def save(self):
623639
if self.path is None:
640+
saveTr = QCoreApplication.translate('PythonConsole',
641+
'Python Console: Save file')
624642
self.path = str(QFileDialog().getSaveFileName(self,
625-
"Python Console: Save file",
643+
saveTr,
626644
"*.py",
627645
"Script file (*.py)"))
628646
# If the user didn't select a file, abort the save operation
@@ -743,7 +761,9 @@ def __init__(self, parent):
743761
self.connect(self.fileTabMenu, SIGNAL("triggered(QAction*)"),
744762
self.showFileTabMenuTriggered)
745763
self.fileTabButton = QToolButton()
746-
self.fileTabButton.setToolTip('List all tabs')
764+
txtToolTipMenuFile = QCoreApplication.translate("PythonConsole",
765+
"List all tabs")
766+
self.fileTabButton.setToolTip(txtToolTipMenuFile)
747767
self.fileTabButton.setIcon(QgsApplication.getThemeIcon("console/iconFileTabsMenuConsole.png"))
748768
self.fileTabButton.setIconSize(QSize(24, 24))
749769
self.fileTabButton.setAutoRaise(True)
@@ -756,7 +776,9 @@ def __init__(self, parent):
756776

757777
# Open button
758778
self.newTabButton = QToolButton()
759-
self.newTabButton.setToolTip('New Tab')
779+
txtToolTipNewTab = QCoreApplication.translate("PythonConsole",
780+
"New Tab")
781+
self.newTabButton.setToolTip(txtToolTipNewTab)
760782
self.newTabButton.setAutoRaise(True)
761783
self.newTabButton.setIcon(QgsApplication.getThemeIcon("console/iconNewTabEditorConsole.png"))
762784
self.newTabButton.setIconSize(QSize(24, 24))
@@ -813,10 +835,13 @@ def _removeTab(self, tab, tab2index=False):
813835
if tab2index:
814836
tab = self.indexOf(tab)
815837
if self.widget(tab).newEditor.isModified():
816-
res = QMessageBox.question( self, 'Python Console: Save File',
817-
'The file <b>"%s"</b> has been modified, save changes ?'
818-
% self.tabText(tab),
819-
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
838+
txtSaveOnRemove = QCoreApplication.translate("PythonConsole",
839+
"Python Console: Save File")
840+
txtMsgSaveOnRemove = QCoreApplication.translate("PythonConsole",
841+
"The file <b>'%1'</b> has been modified, save changes ?").arg(self.tabText(tab))
842+
res = QMessageBox.question( self, txtSaveOnRemove,
843+
txtMsgSaveOnRemove,
844+
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel )
820845
if res == QMessageBox.Save:
821846
self.widget(tab).save()
822847
elif res == QMessageBox.Cancel:
@@ -856,8 +881,11 @@ def restoreTabs(self):
856881
tabName = pathFile.split('/')[-1]
857882
self.newTabEditor(tabName, pathFile)
858883
else:
884+
errOnRestore = QCoreApplication.translate("PythonConsole",
885+
"Unable to restore the file: \n%1\n") \
886+
.arg(pathFile)
859887
print '## Error: '
860-
s = 'Unable to restore the file: \n%s\n' % pathFile
888+
s = errOnRestore
861889
sys.stderr.write(s)
862890
self.parent.updateTabListScript(pathFile)
863891
if self.count() < 1:

0 commit comments

Comments
 (0)
Please sign in to comment.