Explorar o código

Fixed menu sorting

Marcos Dumay de Medeiros %!s(int64=8) %!d(string=hai) anos
pai
achega
c32ee300ea
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      src/rapid/templatetags/rapid_menu.py

+ 6 - 0
src/rapid/templatetags/rapid_menu.py

@@ -5,9 +5,15 @@ from django import template
 from django.utils.safestring import mark_safe
 from django.utils.html import escape
 from rapid.views import registry, ModelData
+from django.utils.translation import to_locale, get_language
 
 register = template.Library()
 
+try:
+    locale.setlocale(locale.LC_ALL, str(to_locale(get_language())))
+except:
+    locale.setlocale(locale.LC_ALL, str('C'))
+
 def _app_menu(app, request):
     models = list(app.models)
     models.sort(key=lambda m: ModelData(m).model_name(), cmp=locale.strcoll)