Blog calendar with international locale
|Reported by:||osimons||Owned by:||pacopablo|
My apache/mod_python setup is configured to use Norwegian for all time and date display. This is fine for all uses (basically timestamps), but when using the calendar it does not display correctly.
What should be 'lø' and 'sø' becomes 'l?' and 's?' as the calendar module seems to use ASCII encoding only. Probably a way around this somehow, but likely a problem for many others as well.
Anyway, as my installation apart from date & time is english, I actually would like to use english for the blog calendar as well - all default Trac is english, and as the blog calender acts as navigation it really looks best with that in english as well.
I have made some simple changes to web_ui.py that allows a custom locale for calendar rendering - for me it solves the encoding problem + gives me the language I want.
def _generate_calendar(self, req, tallies): """Generate data necessary for the calendar""" import locale current_locale = locale.getlocale(category=locale.LC_TIME) locale.setlocale(locale.LC_TIME, 'en') now = datetime.datetime.now() # start of existing code .... .... locale.setlocale(locale.LC_TIME, current_locale) # added a reset pass # could probably be dropped from existing code...
Might I suggest yet another setting in trac.ini/webadmin for locale setting - if empty, don't run the locale switch code, if specified (like en here) then switch.