localized string sorting

This commit is contained in:
M2j 2011-05-23 22:42:07 +02:00
parent a0b3fa82e1
commit 06d561f9fc
4 changed files with 10 additions and 13 deletions

View File

@ -28,6 +28,7 @@ import os
import zipfile
import shutil
import logging
import locale
from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui
@ -461,7 +462,7 @@ class ThemeManager(QtGui.QWidget):
QtCore.QVariant(theme.theme_name))
self.configUpdated()
files = SettingsManager.get_files(self.settingsSection, u'.png')
files.sort()
files.sort(key=lambda filename: unicode(filename), cmp=locale.strcoll)
# now process the file list of png files
for name in files:
# check to see file is in theme root directory

View File

@ -30,6 +30,7 @@ import csv
import logging
import os
import os.path
import locale
from PyQt4 import QtCore, QtGui
@ -531,7 +532,7 @@ class BibleImportForm(OpenLPWizard):
"""
self.webTranslationComboBox.clear()
bibles = self.web_bible_list[index].keys()
bibles.sort()
bibles.sort(cmp=locale.strcoll)
self.webTranslationComboBox.addItems(bibles)
def onOsisBrowseButtonClicked(self):
@ -765,4 +766,4 @@ class BibleImportForm(OpenLPWizard):
self.progressLabel.setText(translate(
'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
del self.manager.db_cache[importer.name]
delete_database(self.plugin.settingsSection, importer.file)
delete_database(self.plugin.settingsSection, importer.file)

View File

@ -25,6 +25,7 @@
###############################################################################
import logging
import locale
from PyQt4 import QtCore, QtGui
@ -358,7 +359,7 @@ class BibleMediaItem(MediaManagerItem):
self.advancedSecondComboBox.addItem(u'')
# Get all bibles and sort the list.
bibles = self.parent.manager.get_bibles().keys()
bibles.sort()
bibles.sort(cmp=locale.strcoll)
# Load the bibles into the combo boxes.
for bible in bibles:
if bible:
@ -442,7 +443,7 @@ class BibleMediaItem(MediaManagerItem):
if bible:
book_data = bibles[bible].get_books()
books = [book.name + u' ' for book in book_data]
books.sort()
books.sort(cmp=locale.strcoll)
add_widget_completer(books, self.quickSearchEdit)
def onImportClick(self):

View File

@ -229,7 +229,8 @@ class SongMediaItem(MediaManagerItem):
def displayResultsSong(self, searchresults):
log.debug(u'display results Song')
self.listView.clear()
searchresults.sort(cmp=self.collateSongTitles)
searchresults.sort(key=lambda song: unicode(song.title),
cmp=locale.strcoll)
for song in searchresults:
author_list = [author.display_name for author in song.authors]
song_title = unicode(song.title)
@ -475,13 +476,6 @@ class SongMediaItem(MediaManagerItem):
Receiver.send_message(u'service_item_update',
u'%s:%s' % (editId, item._uuid))
def collateSongTitles(self, song_1, song_2):
"""
Locale aware collation of song titles
"""
return locale.strcoll(unicode(song_1.title.lower()),
unicode(song_2.title.lower()))
def search(self, string):
"""
Search for some songs