From 9736707e5b1e003613a907943c44fa497b6a0cb3 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 6 Sep 2012 11:31:27 +0200 Subject: [PATCH 1/3] Fixed bug #1046599: String substitution cannot be done for translate() funciton and for QString type. --- openlp/core/ui/advancedtab.py | 2 +- openlp/core/ui/mainwindow.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index c31728a11..48fa54e8d 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -686,7 +686,7 @@ class AdvancedTab(SettingsTab): 'Are you sure you want to change the location of the OpenLP ' 'data directory to:\n\n%s\n\n' 'The data directory will be changed when OpenLP is closed.' - % new_data_path), + ).replace('%s', new_data_path), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 87a650a30..5ff851026 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -1517,7 +1517,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): translate('OpenLP.MainWindow', 'Copying OpenLP data to new data directory location - %s ' '- Please wait for copy to finish' - % self.newDataPath)) + ).replace('%s', self.newDataPath)) dir_util.copy_tree(old_data_path, self.newDataPath) log.info(u'Copy sucessful') except (IOError, os.error, DistutilsFileError), why: @@ -1527,7 +1527,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): translate('OpenLP.MainWindow', 'New Data Directory Error'), translate('OpenLP.MainWindow', 'OpenLP Data directory copy failed\n\n%s' - % unicode(why)), + ).replace('%s', unicode(why)), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Ok)) return False From 9ecca162bd526931de839d60b16630ec9c551096 Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 6 Sep 2012 15:49:47 +0200 Subject: [PATCH 2/3] Additional translate() substitution fixes in openlp.core modules. --- openlp/core/ui/advancedtab.py | 4 ++-- openlp/core/ui/mainwindow.py | 2 +- openlp/core/ui/servicemanager.py | 2 +- openlp/core/ui/thememanager.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 48fa54e8d..2d6b534c4 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -527,7 +527,7 @@ class AdvancedTab(SettingsTab): 'Click "No" to stop loading OpenLP. allowing you to fix ' 'the the problem.\n\n' 'Click "Yes" to reset the data directory to the default ' - 'location.' % self.currentDataPath), + 'location.').replace('%s', self.currentDataPath), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), @@ -750,7 +750,7 @@ class AdvancedTab(SettingsTab): 'The location you have selected \n\n%s\n\n' 'appears to contain OpenLP data files. Do you wish to replace ' 'these files with the current data files?' - % os.path.abspath(data_path,)), + ).replace('%s', os.path.abspath(data_path,)), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 5ff851026..585aba15b 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -998,7 +998,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): 'settings file.\n\n' 'Section [%s] is not valid \n\n' 'Processing has terminated and no changed have been made.' - % section), + ).replace('%s', section), QtGui.QMessageBox.StandardButtons( QtGui.QMessageBox.Ok)) return diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 841d0fb71..d49c988c6 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -519,7 +519,7 @@ class ServiceManager(QtGui.QWidget): 'Service File Missing')) message = unicode(translate('OpenLP.ServiceManager', 'File missing from service\n\n %s \n\n' - 'Continue saving?' % path_from )) + 'Continue saving?')) % path_from answer = QtGui.QMessageBox.critical(self, title, message, QtGui.QMessageBox.StandardButtons( diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 4bef4446a..5ec75f698 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -518,7 +518,7 @@ class ThemeManager(QtGui.QWidget): translate('OpenLP.ThemeManager', 'Theme Already Exists'), translate('OpenLP.ThemeManager', 'Theme %s already exists. Do you want to replace it?' - % theme_name), + ).replace('%s', theme_name), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No), QtGui.QMessageBox.No) From 3845db3579619258cb2e5664ebb5209c976c76ef Mon Sep 17 00:00:00 2001 From: Martin Zibricky Date: Thu, 6 Sep 2012 19:30:45 +0200 Subject: [PATCH 3/3] Additional translate() substitution fixes in openlp.plugins modules. --- openlp/plugins/songs/lib/powersongimport.py | 10 +++++----- openlp/plugins/songs/lib/zionworximport.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/songs/lib/powersongimport.py b/openlp/plugins/songs/lib/powersongimport.py index 4729b6905..f406cc616 100644 --- a/openlp/plugins/songs/lib/powersongimport.py +++ b/openlp/plugins/songs/lib/powersongimport.py @@ -103,7 +103,7 @@ class PowerSongImport(SongImport): self.logError(unicode(translate('SongsPlugin.PowerSongImport', 'No songs to import.')), unicode(translate('SongsPlugin.PowerSongImport', - 'No %s files found.' % PS_string))) + 'No %s files found.')) % PS_string) return self.importWizard.progressBar.setMaximum(len(self.importSource)) for file in self.importSource: @@ -122,8 +122,8 @@ class PowerSongImport(SongImport): parse_error = True self.logError(os.path.basename(file), unicode( translate('SongsPlugin.PowerSongImport', - 'Invalid %s file. Unexpected byte value.' - % PS_string))) + 'Invalid %s file. Unexpected byte value.')) + % PS_string) break else: if label == u'TITLE': @@ -141,14 +141,14 @@ class PowerSongImport(SongImport): if not self.title: self.logError(os.path.basename(file), unicode( translate('SongsPlugin.PowerSongImport', - 'Invalid %s file. Missing "TITLE" header.' % PS_string))) + 'Invalid %s file. Missing "TITLE" header.')) % PS_string) continue # Check that file had COPYRIGHTLINE label if not found_copyright: self.logError(self.title, unicode( translate('SongsPlugin.PowerSongImport', 'Invalid %s file. Missing "COPYRIGHTLINE" ' - 'header.' % PS_string))) + 'header.')) % PS_string) continue # Check that file had at least one verse if not self.verses: diff --git a/openlp/plugins/songs/lib/zionworximport.py b/openlp/plugins/songs/lib/zionworximport.py index 1a00b3a7c..06a45127d 100644 --- a/openlp/plugins/songs/lib/zionworximport.py +++ b/openlp/plugins/songs/lib/zionworximport.py @@ -91,7 +91,7 @@ class ZionWorxImport(SongImport): self.logError(unicode(translate('SongsPlugin.ZionWorxImport', 'Error reading CSV file.')), unicode(translate('SongsPlugin.ZionWorxImport', - 'Line %d: %s' % (songs_reader.line_num, e)))) + 'Line %d: %s')) % (songs_reader.line_num, e)) return num_records = len(records) log.info(u'%s records found in CSV file' % num_records) @@ -111,7 +111,7 @@ class ZionWorxImport(SongImport): self.logError(unicode(translate( 'SongsPlugin.ZionWorxImport', 'Record %d' % index)), unicode(translate('SongsPlugin.ZionWorxImport', - 'Decoding error: %s' % e))) + 'Decoding error: %s')) % e) continue except TypeError, e: self.logError(unicode(translate( @@ -130,7 +130,7 @@ class ZionWorxImport(SongImport): title = self.title if not self.finish(): self.logError(unicode(translate( - 'SongsPlugin.ZionWorxImport', 'Record %d' % index)) + 'SongsPlugin.ZionWorxImport', 'Record %d')) % index + (u': "' + title + u'"' if title else u'')) def _decode(self, str):