From b831ebd48ed05ccd4977d71e149b0e97600d5958 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 10 Mar 2014 20:53:11 +0100 Subject: [PATCH] Use ICU for locale sort key --- openlp/core/utils/__init__.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 426606987..1e358454f 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -426,17 +426,14 @@ def get_locale_key(string): The corresponding string. """ string = string.lower() - # For Python 3 on platforms other than Windows ICU is not necessary. In those cases locale.strxfrm(str) can be used. - if os.name == 'nt': - global ICU_COLLATOR - if ICU_COLLATOR is None: - import icu - from .languagemanager import LanguageManager - language = LanguageManager.get_language() - icu_locale = icu.Locale(language) - ICU_COLLATOR = icu.Collator.createInstance(icu_locale) - return ICU_COLLATOR.getSortKey(string) - return locale.strxfrm(string).encode() + global ICU_COLLATOR + if ICU_COLLATOR is None: + import icu + from .languagemanager import LanguageManager + language = LanguageManager.get_language() + icu_locale = icu.Locale(language) + ICU_COLLATOR = icu.Collator.createInstance(icu_locale) + return ICU_COLLATOR.getSortKey(string) def get_natural_key(string):