django-sorting: Localization is not working
I am using django soring application:
https://github.com/directeur/django-sorting
I just wonder if there is a way to make local names for sorting filters... E.g. I am trying to localize 开发者_如何学Pythonfollowing:
<th>{% anchor total Rating %}</th>
And using standard django trick
<th>{% anchor total _("Rating") %}</th>
is not helping... Don't know what to do...
you should use the trans template tag from within templates..
https://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#trans-template-tag
UPDATE
If you want the title to be translated, you'll just need to modify the anchor template tag code of django-sorting, for example, looking at the source here:
https://github.com/directeur/django-sorting/blob/master/django_sorting/templatetags/sorting_tags.py
Inside anchor you could modify it, for example, by adding the ugettext function as "_()" when the title is passed to the SortAnchorNode class:
return SortAnchorNode(bits[1].strip(), _(title.strip()))
Or you can choose another place to fire the translation, this is just for demonstration but it should work
that will translate the title you specify in your tag:
{% anchor total "Result" %} //{% anchor field title %}
You need to be sure to have the words you'll pass translated in your dictionaries..
精彩评论