My site is smarter than I am

Published: November 22, 2006. Filed under: Django, Meta.

Looking through my stats today, I found an incoming link from a blog written entirely in Chinese. Now, I don’t read Chinese (I know about half a dozen words of Mandarin, but couldn’t begin to pronounce them with the right tones), so I ran it through Babelfish and found that this person was — apparently — commenting on how “comforting” my site was to him.

This left me somewhat befuddled, until I went back and looked at the comment he’d left here, and then at his screenshot of, sure enough, Chinese characters showing up on the page.

Which reminded me that, way back when I first started putting this site together, I turned on Django’s LocaleMiddleware so I could play with it. In case you’re not familiar with it, LocaleMiddleware reads the Accept-Language header of an incoming HTTP request and uses it to choose one of Django’s available translations for the response.

Apparently I never turned it off, which means that strings from Django’s built-in applications are getting translated, automatically, according to your specified language preferences. Mostly that just means that date formats and some strings from the comments application get translated, but I think it’s cool enough to leave turned on.

I also think it’s pretty darned cool that my site is smarter than I am — I don’t speak Chinese, but my site does!