Changing date format in Trac using mod_wsgi

Trac is a marvelous tool to use for us developers. Unfortunately there are some quirks to it. One is that you can not change the data format in a “normal” way eq. through the admin panel. To change it you have to add a bit of code to the trac.wsgi:

environ['trac.locale'] = 'sv_SE.UTF-8' # Any valid locale will do

Be sure to add it after the “def application” row like this:

...
import os

def application(environ, start_request):
    environ['trac.locale'] = 'sv_SE.UTF-8'
    if not 'trac.env_parent_dir' in environ:
        environ.setdefault('trac.env_path', '/var/trac/my_project')
...

After you have made the change be sure to restart the webserver!
For Apache on Debian:

/etc/init.d/apache2 restart

Tested on Debian Wheezy and Trac v0.12.3

Comments are closed.