Use ICU for locale sort key

This commit is contained in:
Tomas Groth 2014-03-10 20:53:11 +01:00
parent 0091079b76
commit b831ebd48e

View File

@ -426,8 +426,6 @@ def get_locale_key(string):
The corresponding string. The corresponding string.
""" """
string = string.lower() 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 global ICU_COLLATOR
if ICU_COLLATOR is None: if ICU_COLLATOR is None:
import icu import icu
@ -436,7 +434,6 @@ def get_locale_key(string):
icu_locale = icu.Locale(language) icu_locale = icu.Locale(language)
ICU_COLLATOR = icu.Collator.createInstance(icu_locale) ICU_COLLATOR = icu.Collator.createInstance(icu_locale)
return ICU_COLLATOR.getSortKey(string) return ICU_COLLATOR.getSortKey(string)
return locale.strxfrm(string).encode()
def get_natural_key(string): def get_natural_key(string):