@@ -472,23 +472,30 @@ def _runSubProcess(self, filename, tmp=False):
472
472
pass
473
473
else :
474
474
raise e
475
+ tmpFileTr = QCoreApplication .translate ('PythonConsole' , ' [Temporary file saved in ' )
475
476
if tmp :
476
- name = name + ' [Temporary file saved in ' + dir + ']'
477
+ name = name + tmpFileTr + dir + ']'
477
478
if _traceback :
479
+ msgTraceTr = QCoreApplication .translate ('PythonConsole' , '## Script error: %1' ).arg (name )
478
480
print "## %s" % datetime .datetime .now ()
479
- print "## Script error: %s" % name
481
+ print msgTraceTr
480
482
sys .stderr .write (_traceback )
481
483
p .stderr .close ()
482
484
else :
485
+ msgSuccessTr = QCoreApplication .translate ('PythonConsole' ,
486
+ '## Script executed successfully: %1' ).arg (name )
483
487
print "## %s" % datetime .datetime .now ()
484
- print "## Script executed successfully: %s" % name
488
+ print msgSuccessTr
485
489
sys .stdout .write (out )
486
490
p .stdout .close ()
487
491
del p
488
492
if tmp :
489
493
os .remove (filename )
490
494
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
492
499
except :
493
500
s = traceback .format_exc ()
494
501
print '## Error: '
@@ -535,7 +542,8 @@ def getTextFromEditor(self):
535
542
536
543
def goToLine (self , objName , linenr ):
537
544
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 ))
539
547
self .SendScintilla (QsciScintilla .SCI_SETTARGETEND , len (self .text ()))
540
548
pos = self .SendScintilla (QsciScintilla .SCI_SEARCHINTARGET , len (objName ), objName )
541
549
index = pos - self .SendScintilla (QsciScintilla .SCI_GETCURRENTPOS )
@@ -557,7 +565,10 @@ def focusInEvent(self, e):
557
565
try :
558
566
file = open (pathfile , "r" ).readlines ()
559
567
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
561
572
for line in reversed (file ):
562
573
self .insert (line )
563
574
QApplication .restoreOverrideCursor ()
@@ -566,7 +577,9 @@ def focusInEvent(self, e):
566
577
567
578
self .parent .tw .listObject (self .parent .tw .currentWidget ())
568
579
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 )
570
583
self .parent .pc .callWidgetMessageBarEditor (msgText , 1 , False )
571
584
572
585
QsciScintilla .focusInEvent (self , e )
@@ -609,7 +622,10 @@ def loadFile(self, filename, modified):
609
622
try :
610
623
fn = open (unicode (filename ), "rb" )
611
624
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
613
629
QApplication .setOverrideCursor (QCursor (Qt .WaitCursor ))
614
630
txt = fn .read ()
615
631
fn .close ()
@@ -621,8 +637,10 @@ def loadFile(self, filename, modified):
621
637
622
638
def save (self ):
623
639
if self .path is None :
640
+ saveTr = QCoreApplication .translate ('PythonConsole' ,
641
+ 'Python Console: Save file' )
624
642
self .path = str (QFileDialog ().getSaveFileName (self ,
625
- "Python Console: Save file" ,
643
+ saveTr ,
626
644
"*.py" ,
627
645
"Script file (*.py)" ))
628
646
# If the user didn't select a file, abort the save operation
@@ -743,7 +761,9 @@ def __init__(self, parent):
743
761
self .connect (self .fileTabMenu , SIGNAL ("triggered(QAction*)" ),
744
762
self .showFileTabMenuTriggered )
745
763
self .fileTabButton = QToolButton ()
746
- self .fileTabButton .setToolTip ('List all tabs' )
764
+ txtToolTipMenuFile = QCoreApplication .translate ("PythonConsole" ,
765
+ "List all tabs" )
766
+ self .fileTabButton .setToolTip (txtToolTipMenuFile )
747
767
self .fileTabButton .setIcon (QgsApplication .getThemeIcon ("console/iconFileTabsMenuConsole.png" ))
748
768
self .fileTabButton .setIconSize (QSize (24 , 24 ))
749
769
self .fileTabButton .setAutoRaise (True )
@@ -756,7 +776,9 @@ def __init__(self, parent):
756
776
757
777
# Open button
758
778
self .newTabButton = QToolButton ()
759
- self .newTabButton .setToolTip ('New Tab' )
779
+ txtToolTipNewTab = QCoreApplication .translate ("PythonConsole" ,
780
+ "New Tab" )
781
+ self .newTabButton .setToolTip (txtToolTipNewTab )
760
782
self .newTabButton .setAutoRaise (True )
761
783
self .newTabButton .setIcon (QgsApplication .getThemeIcon ("console/iconNewTabEditorConsole.png" ))
762
784
self .newTabButton .setIconSize (QSize (24 , 24 ))
@@ -813,10 +835,13 @@ def _removeTab(self, tab, tab2index=False):
813
835
if tab2index :
814
836
tab = self .indexOf (tab )
815
837
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 )
820
845
if res == QMessageBox .Save :
821
846
self .widget (tab ).save ()
822
847
elif res == QMessageBox .Cancel :
@@ -856,8 +881,11 @@ def restoreTabs(self):
856
881
tabName = pathFile .split ('/' )[- 1 ]
857
882
self .newTabEditor (tabName , pathFile )
858
883
else :
884
+ errOnRestore = QCoreApplication .translate ("PythonConsole" ,
885
+ "Unable to restore the file: \n %1\n " ) \
886
+ .arg (pathFile )
859
887
print '## Error: '
860
- s = 'Unable to restore the file: \n %s \n ' % pathFile
888
+ s = errOnRestore
861
889
sys .stderr .write (s )
862
890
self .parent .updateTabListScript (pathFile )
863
891
if self .count () < 1 :
0 commit comments