Commit b067e794 authored by Michal Čihař's avatar Michal Čihař

More readable code for PyICU handling

parent 8db56ba9
...@@ -30,7 +30,7 @@ from django.utils.encoding import force_unicode ...@@ -30,7 +30,7 @@ from django.utils.encoding import force_unicode
from itertools import chain from itertools import chain
try: try:
from icu import Locale, Collator import icu
HAS_ICU = True HAS_ICU = True
except ImportError: except ImportError:
HAS_ICU = False HAS_ICU = False
...@@ -45,7 +45,9 @@ def sort_choices(choices): ...@@ -45,7 +45,9 @@ def sort_choices(choices):
if not HAS_ICU: if not HAS_ICU:
sorter = cmp sorter = cmp
else: else:
sorter = Collator.createInstance(Locale(get_language())).compare locale = icu.Locale(get_language())
collator = icu.Collator.createInstance(locale)
sorter = collator.compare
# Actually sort values # Actually sort values
return sorted( return sorted(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment