← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~mzibricky/openlp/bug-1046599 into lp:openlp

 

matysek has proposed merging lp:~mzibricky/openlp/bug-1046599 into lp:openlp.

Requested reviews:
  Raoul Snyman (raoul-snyman)
  Jonathan Corwin (j-corwin)
Related bugs:
  Bug #1046599 in OpenLP: "set Data Location fails with non-english set Data Location fails with non-english characters"
  https://bugs.launchpad.net/openlp/+bug/1046599

For more details, see:
https://code.launchpad.net/~mzibricky/openlp/bug-1046599/+merge/123134

This fixes the related bug when changing data location to a path with non-english characters.

It was caused by incorrect formatting of string submitted to translate() function. Code like

translate('OpenLP.AdvancedTab', 'data directory to:\n\n%s\n\n' % new_data_path)

- works with english filenames
- this string is modified with a non-constant value before passing to translation

workaround is

translate('OpenLP.AdvancedTab', 'data directory to:\n\n%s\n\n').replace('%s', new_data_path)

- returned string is QString() thus python substitution with '%s' does not work

Conclusion:
- we should review the UI code and do similar fixes where string is modified before passing to translate()
- I'm pretty sure fixing other places will solve more reported bugs and probably prevent new bugs caused by this issue.
-- 
https://code.launchpad.net/~mzibricky/openlp/bug-1046599/+merge/123134
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py	2012-07-15 11:59:55 +0000
+++ openlp/core/ui/advancedtab.py	2012-09-06 17:37:22 +0000
@@ -527,7 +527,7 @@
                 '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),
@@ -686,7 +686,7 @@
                 '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),
@@ -750,7 +750,7 @@
                 '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),

=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py	2012-08-04 17:09:12 +0000
+++ openlp/core/ui/mainwindow.py	2012-09-06 17:37:22 +0000
@@ -998,7 +998,7 @@
                     '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
@@ -1517,7 +1517,7 @@
                     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 @@
                     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

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2012-08-24 20:06:56 +0000
+++ openlp/core/ui/servicemanager.py	2012-09-06 17:37:22 +0000
@@ -519,7 +519,7 @@
                             '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(

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2012-09-05 22:00:26 +0000
+++ openlp/core/ui/thememanager.py	2012-09-06 17:37:22 +0000
@@ -518,7 +518,7 @@
             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)

=== modified file 'openlp/plugins/songs/lib/powersongimport.py'
--- openlp/plugins/songs/lib/powersongimport.py	2012-06-22 14:14:53 +0000
+++ openlp/plugins/songs/lib/powersongimport.py	2012-09-06 17:37:22 +0000
@@ -103,7 +103,7 @@
             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 @@
                         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 @@
             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:

=== modified file 'openlp/plugins/songs/lib/zionworximport.py'
--- openlp/plugins/songs/lib/zionworximport.py	2012-06-26 14:58:08 +0000
+++ openlp/plugins/songs/lib/zionworximport.py	2012-09-06 17:37:22 +0000
@@ -91,7 +91,7 @@
                 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 @@
                     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 @@
                 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):


Follow ups