Themes and User Language Selection

Topics: Themes
Mar 21, 2008 at 8:05 PM
Hi Everyone,

I'm working on creating a theme that I need for my blog. I am planning on submitting it to the BlogEngine.NET community under a LGPL or Creative Commons license.

However, I'm running into an issue that I wasn't sure how to solve.

Basically, I want to add a language selector drop-down (or links) to the theme, similar to what I hand-rolled on our free community forums (formerly dating) site I know that BlogEngine.NET already has multi-language capabilities in the Admin/Settings tab. However, this appeared to be on a global level. I wanted to give the User the ability to choose his/her language.

I hacked the BlogEngine source code to do it for our blog However, the code is ugly, and I hate to modify anything in our implementation of BlogEngine.NET (outside of the themes directory). My belief has always been that one should only modify a product (even open source ones) where they were meant to be modified, otherwise as new versions of BlogEngine.NET come out, our ZenDear site blog is going to be stuck on an older version.

Once I'm done with this theme, I want to replace our modded implementation of BlogEngine.NET on with a standard implementation that uses a theme.

The problem I'm running into is that I need to store the User's Language selection ... someplace. Naturally, I would store it in the Session. However, I noticed that the Web.Config specifies EnableSessionState as false, so I do not have access to the Session.

I'm really very hesitant to require that anyone using the theme I'm creating go in and change settings in the Web.Config. If it's just me using it, I have no problems here. However, it's something I want to donate back to the community, and I don't want others to have to mod their Web.Config if they want to use this particular theme.

Here are my questions:

1. Does BlogEngine.NET have any User objects/settings/caches that would be appropriate to store the current User's selected language? I did find this block of code in the Global.asax:

void Application_PreRequestHandlerExecute(object sender, EventArgs e)
if (!string.IsNullOrEmpty(BlogSettings.Instance.Culture))
if (!BlogSettings.Instance.Culture.Equals("Auto"))
CultureInfo culture = CultureInfo.CreateSpecificCulture(BlogSettings.Instance.Culture);
Thread.CurrentThread.CurrentUICulture = culture;
Thread.CurrentThread.CurrentCulture = culture;

However, this seems to be what is setting the Blog's language based on what the admin selects under settings.

2. Can anyone think of another mechanism where I could only turn on EnableSessionState for MY theme? I tried a few things, like adding a simple Web.Config to my specific theme directory,

<?xml version="1.0"?>
<pages enableSessionState="true" />

But IIS doesn't seem to pick this up (presumably because all my theme directory holds is the Master page and not the actual page being run.

3. Any other way without the Session to retain the User's selection? I suppose I could use Cookies, but I've always avoided them whenever possible.

Well, for what it's worth, I've had a lot of fun working with BlogEngine.NET. The code is VERY well written ... I've been playing with the source and found it clean and easy to understand. Kudos to the development team for one heck of a nice product.

Thanks in advance, everyone!