Localized string collator in Django -
is there simple way how string collator current set language in django (1.11)? need use sort accented strings.
in theory should working:
import locale django.utils.translation import to_locale, get_language locale.setlocale(locale.lc_all, to_locale(get_language())) sorted(..., cmp=locale.strcoll)
but doesn't. to_locale
not return correct formatted locale, e.g. czech language returns cs
, whereas system locale called cs_cz
. looks kinda unpythonic , undjangoish me. considering how easy internationalization in django, suspect there should from django.utils.translation import get_strcoll
, apparently not.
can me out? thank you.
Comments
Post a Comment