forked from openlp/openlp
Changed get_locale_key to only use ICU if available.
This commit is contained in:
parent
2b55da02c1
commit
5ac6f853d0
|
@ -426,7 +426,9 @@ def get_locale_key(string):
|
||||||
The corresponding string.
|
The corresponding string.
|
||||||
"""
|
"""
|
||||||
string = string.lower()
|
string = string.lower()
|
||||||
|
# ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases.
|
||||||
global ICU_COLLATOR
|
global ICU_COLLATOR
|
||||||
|
try:
|
||||||
if ICU_COLLATOR is None:
|
if ICU_COLLATOR is None:
|
||||||
import icu
|
import icu
|
||||||
from .languagemanager import LanguageManager
|
from .languagemanager import LanguageManager
|
||||||
|
@ -434,7 +436,8 @@ 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)
|
||||||
|
except:
|
||||||
|
return locale.strxfrm(string).encode()
|
||||||
|
|
||||||
def get_natural_key(string):
|
def get_natural_key(string):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue