Two posts back I was writing about my plans to implement language negotiation forĀ getgnulinux.
“Language negotiation is a function of the HTTP protocol which lets a server choose among several language versions of a page, based on the URL and on preference information sent by the browser (specifically in the
Accept-Languageheader).” – http://www.w3.org/International/questions/qa-when-lang-neg
Before language negotiation was implemented, http://
Other changes came along with the implementation of language negotiation. The language menu on the top of each page now only shows the languages for which the translation is complete. Incomplete translations are still accessible from the “More languages” item in the language menu. This link brings the user to the new language selection page which gives an overview of all translations and their status.
The implementation of language negotiation was actually very simple. Language negotiation is a common feature for websites which means that there is a good chance that someone has already written freely available code for it. And indeed, someone has. There is HTTP::negotiateLanguage from PEAR, PHP’s own structured library of code. However, I used a modified version of that function which I got from Matthew Somerville’s website. The reason I chose Somerville’s version is because apparently PEAR’s version fails on one criterion (see Somerville’s page for details). This also allowed me to adapt some code to GGL’s code which made implementation even easier.