forked from openlp/openlp
use ICU collator on Windows systems
This commit is contained in:
parent
cbf91465e2
commit
15449372e1
@ -29,7 +29,6 @@ import os
|
|||||||
import zipfile
|
import zipfile
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import locale
|
|
||||||
|
|
||||||
from xml.etree.ElementTree import ElementTree, XML
|
from xml.etree.ElementTree import ElementTree, XML
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -44,7 +43,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
|||||||
from openlp.core.theme import Theme
|
from openlp.core.theme import Theme
|
||||||
from openlp.core.ui import FileRenameForm, ThemeForm
|
from openlp.core.ui import FileRenameForm, ThemeForm
|
||||||
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
from openlp.core.utils import AppLocation, delete_file, file_is_unicode, \
|
||||||
get_filesystem_encoding
|
get_filesystem_encoding, get_local_collator
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -458,7 +457,7 @@ class ThemeManager(QtGui.QWidget):
|
|||||||
# Sort the themes by its name considering language specific characters.
|
# Sort the themes by its name considering language specific characters.
|
||||||
# lower() is needed for windows!
|
# lower() is needed for windows!
|
||||||
files.sort(key=lambda filename: unicode(filename).lower(),
|
files.sort(key=lambda filename: unicode(filename).lower(),
|
||||||
cmp=locale.strcoll)
|
cmp=get_local_collator)
|
||||||
# now process the file list of png files
|
# now process the file list of png files
|
||||||
for name in files:
|
for name in files:
|
||||||
# check to see file is in theme root directory
|
# check to see file is in theme root directory
|
||||||
|
@ -33,6 +33,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import urllib2
|
import urllib2
|
||||||
|
import locale
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
@ -45,6 +46,18 @@ if sys.platform != u'win32' and sys.platform != u'darwin':
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
XDG_BASE_AVAILABLE = False
|
XDG_BASE_AVAILABLE = False
|
||||||
|
|
||||||
|
LOCALE_COLLATOR = locale.strcoll
|
||||||
|
if sys.platform == u'win32':
|
||||||
|
try:
|
||||||
|
import icu
|
||||||
|
try:
|
||||||
|
icu_locale = icu.Locale(locale.getlocale()[0])
|
||||||
|
LOCALE_COLLATOR = icu.Collator.createInstance(icu_locale).compare
|
||||||
|
except icu.InvalidArgsError:
|
||||||
|
pass
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
import openlp
|
import openlp
|
||||||
from openlp.core.lib import Receiver, translate, check_directory_exists
|
from openlp.core.lib import Receiver, translate, check_directory_exists
|
||||||
|
|
||||||
@ -502,10 +515,17 @@ def get_uno_instance(resolver):
|
|||||||
return resolver.resolve(u'uno:socket,host=localhost,port=2002;' \
|
return resolver.resolve(u'uno:socket,host=localhost,port=2002;' \
|
||||||
+ u'urp;StarOffice.ComponentContext')
|
+ u'urp;StarOffice.ComponentContext')
|
||||||
|
|
||||||
|
def get_local_collator(string1, string2):
|
||||||
|
"""
|
||||||
|
Returns a collator for locale aware string sorting.
|
||||||
|
"""
|
||||||
|
return LOCALE_COLLATOR(string1, string2)
|
||||||
|
|
||||||
from languagemanager import LanguageManager
|
from languagemanager import LanguageManager
|
||||||
from actions import ActionList
|
from actions import ActionList
|
||||||
|
|
||||||
__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
|
__all__ = [u'AppLocation', u'get_application_version', u'check_latest_version',
|
||||||
u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
|
u'add_actions', u'get_filesystem_encoding', u'LanguageManager',
|
||||||
u'ActionList', u'get_web_page', u'file_is_unicode', u'get_uno_command',
|
u'ActionList', u'get_web_page', u'file_is_unicode', u'get_uno_command',
|
||||||
u'get_uno_instance', u'delete_file', u'clean_filename']
|
u'get_uno_instance', u'get_local_collator', u'delete_file',
|
||||||
|
u'clean_filename']
|
||||||
|
@ -30,7 +30,6 @@ The bible import functions for OpenLP
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ from openlp.core.lib import Receiver, translate
|
|||||||
from openlp.core.lib.db import delete_database
|
from openlp.core.lib.db import delete_database
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation, get_local_collator
|
||||||
from openlp.plugins.bibles.lib.manager import BibleFormat
|
from openlp.plugins.bibles.lib.manager import BibleFormat
|
||||||
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
|
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
|
||||||
|
|
||||||
@ -522,7 +521,7 @@ class BibleImportForm(OpenLPWizard):
|
|||||||
"""
|
"""
|
||||||
self.webTranslationComboBox.clear()
|
self.webTranslationComboBox.clear()
|
||||||
bibles = self.web_bible_list[index].keys()
|
bibles = self.web_bible_list[index].keys()
|
||||||
bibles.sort(cmp=locale.strcoll)
|
bibles.sort(cmp=get_local_collator)
|
||||||
self.webTranslationComboBox.addItems(bibles)
|
self.webTranslationComboBox.addItems(bibles)
|
||||||
|
|
||||||
def onOsisBrowseButtonClicked(self):
|
def onOsisBrowseButtonClicked(self):
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -36,6 +35,7 @@ from openlp.core.lib.searchedit import SearchEdit
|
|||||||
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
|
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
|
||||||
media_item_combo_box, critical_error_message_box, \
|
media_item_combo_box, critical_error_message_box, \
|
||||||
find_and_set_in_combo_box, build_icon
|
find_and_set_in_combo_box, build_icon
|
||||||
|
from openlp.core.utils import get_local_collator
|
||||||
from openlp.plugins.bibles.forms import BibleImportForm
|
from openlp.plugins.bibles.forms import BibleImportForm
|
||||||
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
|
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
|
||||||
VerseReferenceList, get_reference_match
|
VerseReferenceList, get_reference_match
|
||||||
@ -373,7 +373,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
self.advancedSecondComboBox.addItem(u'')
|
self.advancedSecondComboBox.addItem(u'')
|
||||||
# Get all bibles and sort the list.
|
# Get all bibles and sort the list.
|
||||||
bibles = self.plugin.manager.get_bibles().keys()
|
bibles = self.plugin.manager.get_bibles().keys()
|
||||||
bibles.sort(cmp=locale.strcoll)
|
bibles.sort(cmp=get_local_collator)
|
||||||
# Load the bibles into the combo boxes.
|
# Load the bibles into the combo boxes.
|
||||||
for bible in bibles:
|
for bible in bibles:
|
||||||
if bible:
|
if bible:
|
||||||
@ -481,7 +481,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
book_data_temp.append(book)
|
book_data_temp.append(book)
|
||||||
book_data = book_data_temp
|
book_data = book_data_temp
|
||||||
books = [book.name + u' ' for book in book_data]
|
books = [book.name + u' ' for book in book_data]
|
||||||
books.sort(cmp=locale.strcoll)
|
books.sort(cmp=get_local_collator)
|
||||||
add_widget_completer(books, self.quickSearchEdit)
|
add_widget_completer(books, self.quickSearchEdit)
|
||||||
|
|
||||||
def onQuickVersionComboBox(self):
|
def onQuickVersionComboBox(self):
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from sqlalchemy.sql import or_, func
|
from sqlalchemy.sql import or_, func
|
||||||
@ -35,6 +34,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
|
|||||||
check_item_selected, translate
|
check_item_selected, translate
|
||||||
from openlp.core.lib.searchedit import SearchEdit
|
from openlp.core.lib.searchedit import SearchEdit
|
||||||
from openlp.core.lib.ui import UiStrings
|
from openlp.core.lib.ui import UiStrings
|
||||||
|
from oprnlp.core.utils import get_local_collator
|
||||||
from openlp.plugins.custom.forms import EditCustomForm
|
from openlp.plugins.custom.forms import EditCustomForm
|
||||||
from openlp.plugins.custom.lib import CustomXMLParser
|
from openlp.plugins.custom.lib import CustomXMLParser
|
||||||
from openlp.plugins.custom.lib.db import CustomSlide
|
from openlp.plugins.custom.lib.db import CustomSlide
|
||||||
@ -137,7 +137,7 @@ class CustomMediaItem(MediaManagerItem):
|
|||||||
# Sort the customs by its title considering language specific
|
# Sort the customs by its title considering language specific
|
||||||
# characters. lower() is needed for windows!
|
# characters. lower() is needed for windows!
|
||||||
custom_slides.sort(
|
custom_slides.sort(
|
||||||
cmp=locale.strcoll, key=lambda custom: custom.title.lower())
|
cmp=get_local_collator, key=lambda custom: custom.title.lower())
|
||||||
for custom_slide in custom_slides:
|
for custom_slide in custom_slides:
|
||||||
custom_name = QtGui.QListWidgetItem(custom_slide.title)
|
custom_name = QtGui.QListWidgetItem(custom_slide.title)
|
||||||
custom_name.setData(
|
custom_name.setData(
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -35,7 +34,8 @@ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
|
|||||||
SettingsManager, translate, check_item_selected, check_directory_exists, \
|
SettingsManager, translate, check_item_selected, check_directory_exists, \
|
||||||
Receiver, create_thumb, validate_thumb
|
Receiver, create_thumb, validate_thumb
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.utils import AppLocation, delete_file, get_images_filter
|
from openlp.core.utils import AppLocation, delete_file, get_images_filter, \
|
||||||
|
get_local_collator
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class ImageMediaItem(MediaManagerItem):
|
|||||||
self.plugin.formparent.displayProgressBar(len(images))
|
self.plugin.formparent.displayProgressBar(len(images))
|
||||||
# Sort the themes by its filename considering language specific
|
# Sort the themes by its filename considering language specific
|
||||||
# characters. lower() is needed for windows!
|
# characters. lower() is needed for windows!
|
||||||
images.sort(cmp=locale.strcoll,
|
images.sort(cmp=get_local_collator,
|
||||||
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
||||||
for imageFile in images:
|
for imageFile in images:
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -37,6 +36,7 @@ from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
|
|||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||||
media_item_combo_box
|
media_item_combo_box
|
||||||
from openlp.core.ui import Controller, Display
|
from openlp.core.ui import Controller, Display
|
||||||
|
from openlp.core.utils import get_local_collator
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
def loadList(self, media):
|
def loadList(self, media):
|
||||||
# Sort the themes by its filename considering language specific
|
# Sort the themes by its filename considering language specific
|
||||||
# characters. lower() is needed for windows!
|
# characters. lower() is needed for windows!
|
||||||
media.sort(cmp=locale.strcoll,
|
media.sort(cmp=get_local_collator,
|
||||||
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
||||||
for track in media:
|
for track in media:
|
||||||
track_info = QtCore.QFileInfo(track)
|
track_info = QtCore.QFileInfo(track)
|
||||||
@ -298,7 +298,7 @@ class MediaMediaItem(MediaManagerItem):
|
|||||||
|
|
||||||
def getList(self, type=MediaType.Audio):
|
def getList(self, type=MediaType.Audio):
|
||||||
media = SettingsManager.load_list(self.settingsSection, u'media')
|
media = SettingsManager.load_list(self.settingsSection, u'media')
|
||||||
media.sort(cmp=locale.strcoll,
|
media.sort(cmp=get_local_collator,
|
||||||
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
||||||
ext = []
|
ext = []
|
||||||
if type == MediaType.Audio:
|
if type == MediaType.Audio:
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import locale
|
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
@ -36,6 +35,7 @@ from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
|
|||||||
validate_thumb
|
validate_thumb
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box, \
|
||||||
media_item_combo_box
|
media_item_combo_box
|
||||||
|
from openlp.core.utils import get_local_collator
|
||||||
from openlp.plugins.presentations.lib import MessageListener
|
from openlp.plugins.presentations.lib import MessageListener
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -168,7 +168,7 @@ class PresentationMediaItem(MediaManagerItem):
|
|||||||
self.plugin.formparent.displayProgressBar(len(files))
|
self.plugin.formparent.displayProgressBar(len(files))
|
||||||
# Sort the themes by its filename considering language specific
|
# Sort the themes by its filename considering language specific
|
||||||
# characters. lower() is needed for windows!
|
# characters. lower() is needed for windows!
|
||||||
files.sort(cmp=locale.strcoll,
|
files.sort(cmp=get_local_collator,
|
||||||
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
key=lambda filename: os.path.split(unicode(filename))[1].lower())
|
||||||
for file in files:
|
for file in files:
|
||||||
if not initialLoad:
|
if not initialLoad:
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
The :mod:`songexportform` module provides the wizard for exporting songs to the
|
The :mod:`songexportform` module provides the wizard for exporting songs to the
|
||||||
OpenLyrics format.
|
OpenLyrics format.
|
||||||
"""
|
"""
|
||||||
import locale
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
@ -36,6 +35,7 @@ from PyQt4 import QtCore, QtGui
|
|||||||
from openlp.core.lib import build_icon, Receiver, SettingsManager, translate
|
from openlp.core.lib import build_icon, Receiver, SettingsManager, translate
|
||||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
from openlp.core.lib.ui import UiStrings, critical_error_message_box
|
||||||
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
||||||
|
from openlp.core.utils import get_local_collator
|
||||||
from openlp.plugins.songs.lib.db import Song
|
from openlp.plugins.songs.lib.db import Song
|
||||||
from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport
|
from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class SongExportForm(OpenLPWizard):
|
|||||||
# Load the list of songs.
|
# Load the list of songs.
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
songs = self.plugin.manager.get_all_objects(Song)
|
songs = self.plugin.manager.get_all_objects(Song)
|
||||||
songs.sort(cmp=locale.strcoll, key=lambda song: song.title.lower())
|
songs.sort(cmp=get_local_collator, key=lambda song: song.title.lower())
|
||||||
for song in songs:
|
for song in songs:
|
||||||
# No need to export temporary songs.
|
# No need to export temporary songs.
|
||||||
if song.temporary:
|
if song.temporary:
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import locale
|
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -39,7 +38,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
|
|||||||
from openlp.core.lib.searchedit import SearchEdit
|
from openlp.core.lib.searchedit import SearchEdit
|
||||||
from openlp.core.lib.ui import UiStrings, context_menu_action, \
|
from openlp.core.lib.ui import UiStrings, context_menu_action, \
|
||||||
context_menu_separator
|
context_menu_separator
|
||||||
from openlp.core.utils import AppLocation
|
from openlp.core.utils import AppLocation, get_local_collator
|
||||||
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
|
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
|
||||||
SongImportForm, SongExportForm
|
SongImportForm, SongExportForm
|
||||||
from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \
|
from openlp.plugins.songs.lib import OpenLyrics, SongXML, VerseType, \
|
||||||
@ -268,7 +267,7 @@ class SongMediaItem(MediaManagerItem):
|
|||||||
# Sort the songs by its title considering language specific characters.
|
# Sort the songs by its title considering language specific characters.
|
||||||
# lower() is needed for windows!
|
# lower() is needed for windows!
|
||||||
searchresults.sort(
|
searchresults.sort(
|
||||||
cmp=locale.strcoll, key=lambda song: song.title.lower())
|
cmp=get_local_collator, key=lambda song: song.title.lower())
|
||||||
for song in searchresults:
|
for song in searchresults:
|
||||||
# Do not display temporary songs
|
# Do not display temporary songs
|
||||||
if song.temporary:
|
if song.temporary:
|
||||||
|
Loading…
Reference in New Issue
Block a user