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

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.