How can I change the language of ?

Skip to first unread message

Christian Specht

Jan 25, 2013, 1:35:12 PM1/25/13
I'm trying to put a list of months with the number of posts per month into the sidebar my blog.

Right now, I'm doing it this way:

    % for link, name, num_posts in
    <li><a href="${bf.util.site_path_helper(,link)}/1">${name}&nbsp;(${num_posts})</a></li>
    % endfor
...which gives me that:
    Mai 2012 (1)
    Februar 2012 (1)
    Mai 2011 (2)
    Juli 2010 (2)
    Juni 2010 (4)

The problem is that the month names are in German.
I'm in Germany and everything on my machine is in German, but I want my site to be in English.

How can I make to return the month names always in English, and not in the language of my machine?

Or is there another way how to get the list of months and the number of posts?
I looked at the code of the "Archive" page.
The months there are returned in English (because I'm setting the locale via import locale and locale.setlocale(locale.LC_ALL, 'english')), but I don't know how to sum up the number of posts per month (it's probably possible in Python, but I don't know Python).


Christian Specht

Feb 2, 2013, 2:19:26 PM2/2/13
Okay...I have a solution. It's not the most elegant way, but it works for me:

    % for link, name, num_posts in
        if name.startswith('Januar'):
        elif name.startswith('Februar'):
        # omit March because the German name makes Blogofile/Mako crash, because it contains an umlaut
        # (there will never be posts in March anyway, because they make Blogofile/Mako crash, too)
        elif name.startswith('Mai'):
        elif name.startswith('Juni'):
        elif name.startswith('Juli'):
        elif name.startswith('Oktober'):
        elif name.startswith('Dezember'):
    <li><a href="${bf.util.site_path_helper(,link)}/1">${month}&nbsp;(${num_posts})</a></li>
    % endfor

Péter Zsoldos

Feb 2, 2013, 2:46:00 PM2/2/13


Just a quick idea from the top of my head - have you tried setting your shell to the desired locale via the LC_* variables? You could even do that in your .profile (.bashrc, etc.) if you wish

Certainly it would be nice to specify this as a blogofile config variable, but this might be a quick workaround.

Disclaimer - haven't tried it, for being laptopless on the train...



You received this message because you are subscribed to the Google Groups "blogofile-discuss" group.
To post to this group, send email to
To unsubscribe from this group, send email to
Visit this group at
For more options, visit

Christian Specht

Feb 2, 2013, 3:47:05 PM2/2/13
Hi Peter,

thank you for your answer!
My shell is cmd.exe (Windows) and apparently you can't "just" set another language there:


Péter Zsoldos

Feb 2, 2013, 4:21:21 PM2/2/13

Ah, python on windows is rather fun, before using it I thought python was a truly cross platform environment... You could always try cygwin (or git-bash), but then it likely won't be that easy.

I wonder whether the pre_build hook would work here - try adding this to your file

def pre_build():
    # do the same import & LC_ALL thing here
    # please double check the function name in the docs

This would happen before the posts are rendered to file, and thus setting the locale here would be applied for all your templates

Let us know whether it works!

You received this message because you are subscribed to the Google Groups "blogofile-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to

To post to this group, send email to

Christian Specht

Feb 4, 2013, 6:06:55 PM2/4/13
Hi Peter, works!

The correct syntax looks like this:

def pre_build():
    import locale
    locale.setlocale(locale.LC_ALL, 'english')

Even better, this also solves another issue I had:
Blogofile crashed when I set the date of any blog post to March, probably of the German umlaut (March is the only month which contains an umlaut in German: "März").

By setting the locale to English in the pre_build hook, that problem just disappeared.

Thank you!

Reply all
Reply to author
0 new messages