Please note: You are reading a machine translation of an article written in German. Accuracy cannot be guaranteed. (view original)
Language functions changed
2010-12-27 23:01:43
The Christmas holidays are a time for many wonderful things: sleep, meet old friends, being with family, eat well. I'm in this time like a little out of most university duties, and do some programming for my own purposes. The last two or three days I've honed my website and overhauled the technical basis for internationalization.
Important changes
First, maybe what has changed for visitors to the site. The most noticeable change: There is no "implicit language mode", but each visitor is at any time on either the German or the English version of the page. (This is to be shown only in German available content on the English side in German, hereby changes nothing.) You notice it because you will be redirected when you visit the page on a subdomain, de.julian-fietkau.de or en.julian-fietkau.de, depending on the language setting of the browser. You can switch as usual over the flag in the footer.
The links look a little different. Instead of giving a language at the end of the link (formerly "http://www.julian-fietkau.de/blog/en") is now the language specified via the subdomain (new "http://en.julian-fietkau.de/blog"). The same applies to direct links to files, if they are ever allowed. The preferred link for communication is still the the "www" without language, so that every visitor gets the link, the language he'd rather have. Each link is with "www" instead of "de" or "en" can and then will make the necessary transfer.
It's basically about it. I'd write a little about why I did it and how it is implemented. Warning in advance: This is again mainly of programmers.
Uniqueness of URLs
I have been since the launch of this version of my page of explicit little unhappy that popular search engine had indexed the first English versions of my bases and the German then only on the indication of the language were available. There seems to be a bad idea to make the language setting by evaluating several language versions of content to be found online at the same URL. Is nice, if users can easily copy and distribute the address from your browser and, but somehow this dynamic adaptation of the language of a URL is a bit too non-deterministic for a working Web and goes against the conventions.
In the current solution, each URL, the content is located behind a clear and explicit language. All others are referrals, if necessary, take into account the language of the user in selecting the forwarding target. The "xml:lang" attribute is now also being set correctly.
About HTTP status codes
I was faced with the challenge to implement the structure so that the new links work and all the old ones remain functional. You never know who has set any bookmarks or possibly where the URLs are everywhere. That the old still work, so I was pretty important. In this sense, each visitor to an old URL with explicit language by stating "301 Moved Permanently" redirected to the new address without having to become annoyed great need.
The other big question was, what I do with the visitors to a page without specifying language now. Simply give out any content I wanted any more. After I have determined whether they prefer to "de" or "en" do have, they are therefore now using "303 See Other" passed on their language version. Thus I bring, according to Wikipedia as opposed to a 301, among other things expressed: "The specified URI is not a substitute reference for the original resource." Should read: "Hey, the visitor, what you have asked can you personally found better here instead, but that is not necessarily true for the rest of the world alike."
The pesky little things
Without too much to talk about boring internals, I can say that most of the time has once again engulfed the small stuff. I had broken in many places the templates to customize and especially the OpenID login the last two days was completely broken. Now hopefully everything should work. If you stumble across any bugs or other anomalies, like, tell me!
P.S. Only an hour long you can admire the Christmas decorations, then they disappear until next December.


Comments
nettes Konzept, ich hatte bisher nicht die Gelegenheit mich mit den HTTP-Statuscodes auseinander zu setzen, klingt aber sehr spannend. Da werden dich demnächst ein paar Fragen erwarten :P Aber um auch mal etwas Kritik anzubringen: 1) Das OpenID Login Feld sieht unschön aus, wennn man noch nicht eingeloggt ist. 2) Ich finde es immer schöner, wenn der Quellcode dem Anwender auch korrekt eingerückt ausgeliefert wird. Diese Seite soll ja als Vorbild dienen (unterstelle ich dir mal) und da möchtest du auch gern in der Quelltext-Konvention vorbildlich sein ;)
Viele Grüße!
3) Die Zeilenumbrüche hier im Kommentarfeld werden nicht berücksichtigt :/
Danke für das Feedback, mit weiteren Fragen zur Technik nur immer raus. :)