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
from itertools import chain
try:
from icu import Locale, Collator
import icu
HAS_ICU = True
except ImportError:
HAS_ICU = False
......@@ -45,7 +45,9 @@ def sort_choices(choices):
if not HAS_ICU:
sorter = cmp
else:
sorter = Collator.createInstance(Locale(get_language())).compare
locale = icu.Locale(get_language())
collator = icu.Collator.createInstance(locale)
sorter = collator.compare
# Actually sort values
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