Making Changes to the Language Functionality of My Website

You are reading an older blog post. Please be aware that the information contained in it may be technologically outdated. This text may not necessarily reflect my current opinions or capabilities.

This is an English translation of a blog post that was originally published in German.

December 27th, 2010

Christmas is a time for many nice things: meeting old friends, being with family, eating well, sleeping in. For this time I like to take a break from most university duties and do some programming for my own personal purposes. I dedicated the past two or three days to my website and overhauled the technical basis for internationalization.

Important Changes

First, what changes for visitors to the site. The most noticeable change: there is no longer an “implicit language mode,” instead each visitor sees either the German or the English version of the page at all times. (This does not change the fact that content only available in German is also displayed in German on the English page). You will notice that you will be redirected to a subdomain, either or, depending on the language settings of your browser. As usual, you can switch via the flag in the footer.

The links look a little different. Instead of a language specification at the end of the link (old: “”), the language is now specified via the subdomain (new: “”). The same applies to direct links to files, as far as they are allowed at all. The preferred link for sharing is still the one with “www” without language, so that every visitor of the link gets the language they prefer. Each link is also available with “www” instead of “de” or “en” and then performs the appropriate redirection.

That is basically all. I'll write a little bit about why I did this and how it is implemented. Warning you beforehand: this is mainly my innter programmer speaking.

Uniqueness of URLs

Since the launch of this version of my site, I've been a bit dissatisfied with the fact that common search engines first indexed the English versions of my sub pages and then the German ones were only available by explicitly specifying the language. It seems like a bad idea to make multiple language versions of content available through the same URL by evaluating the language setting. It's nice if users can just copy the address from their browser and share it, but somehow this dynamic adjustment of the language of a URL is a bit too non-deterministic for a working web and goes against user expectations.

With the current solution, every URL that has content behind it has a unique and explicit language. All others are redirects that may take the user's language setting into account when selecting the redirect destination. By the way, the “xml:lang” attribute is now also set correctly.

About HTTP Status Codes

I was faced with the challenge of implementing the structure so that the new links all work and the old ones remain functional. You never know who has bookmarked something or where the URLs are located. So it was quite important to me that the old ones would continue to work. In this sense, every visitor of an old URL with explicit language information will be redirected to the new address via “301 Moved Permanently” without having to think about it.

The other big question was, what do I do for the visitors of a page without language specification now. I didn't want to simply give out random language content. So after I determine if they prefer “de” or “en,” they are now redirected to their language version via “303 See Other.” According to Wikipedia, this expresses the following in contrast to a 301: “The specified URI is not a substitute reference for the original resource.” Meaning: “Hey visitor! What you requested is best found here in person instead, but that doesn't necessarily apply equally to the rest of the world.”

The Darned Details

Without talking too much about boring internals, I can say that most of my time was taken up by small stuff again. I had to adjust the templates in many places and especially the OpenID login was completely broken for the last two days. Hopefully everything should work now. If you find any bugs or other problems, please let me know!

P.S. You can admire the christmas decorations for another hour, then it will disappear until next December.


You can leave a comment by replying to this Mastodon post from your own account on Mastodon, Firefish, Akkoma, or any other ActivityPub-capable social network that can exchange replies with Mastodon.