i18n and L10n: 3 - HTTP Headers

Article about language selection via HTTP Headers for multilingual portal websites

Author: Matthew Wittering | Published: 8th July 2009

In a world of many languages it is important to identify both the language of the document and the preferred language of the user. The goal should be to find the most appropriate translation of the selected page for the current user. To do so would aid the development and maintenance of relationships between user and organisation.

It is not appropriate to assume a users language based upon their geographical location. While on placement at Andalucia.com S.L. / Andalucia Web Solutions S.L. in Spain, I had a running battle of redirects to the Google España - google.es rather than google.com or google.co.uk.

In the case of Google as a resident of Spain displaying the content in Spanish despite my current geographical location would not be suitable because my preferred language is English. English as written in Great Britain to be correct. At this time Google was ignoring the English British localization of Mozilla Firefox which I had elected to install and redirecting me to google.es despite by browser localization.

If the site uses a registration system to identify users - a fields for preferred languages would allow the user to opt into their language. The storage and association of preferred language with user profile would aid efforts to Localize L10n in a world of misconfiguration and geographical inconsistencies.

Mozilla Firefox

Mozilla Firefox Homepage Screenshot

Screenshot 1: Mozilla Firefox, Credit www.mozilla.com.

A modern standards compliant Internet browser such as Mozilla Firefox allows the user to identify preferred languages:

Firefox speaks your language like no other browser on earth. Because the Web is a worldwide resource and we believe that resource belongs to the people, we’ve made our browser available in as many local languages as possible. We have over 40 different translations, from French and Chinese to Finnish and Czech. Find your language.

Quote 1: Mozilla Firefox Universal Access Features, Credit Mozilla.

Mozilla Firefox like the interfaces of other browser can be customized displaying menu in the users preferred system language. The same is true for web content. Users of Mozilla Firefox, Apple Safari and Webkit browsers allows uses to readily configure the application to create an ordered list of preferable languages to display text content.

The goal of developers working on multilingual systems should be to direct the user to the content composed in the most relevant language for the user. HTTP headers can be used to discover the language preferences of the current user agent and therefore aid in automation of language selection. Despite this goal the facilities must be made apparent to the user to alter the language if incorrect.

HTTP Headers

The Hypertext Transport Protocol is really what makes requesting content in your browser and the Internet as you experience it, work.

HTTP defines eight methods. They indicate the desired action to be performed on the identified resource. The protocol was development by the World Wide Web Consortium and the Internet Engineering Task Force (IETF).

For multilingual portal sites the area of interest for developers is the HEAD region.

Request

When content is requested by the user agent we should inspect the Accept-Language header to identify the users preferred language(s).

Accept-Language

Acceptable languages for response => Accept-Language: en-GB

Response

The response version is the Content-Language which details the language and dialect of the requested content.

Content-Language

The language the content is in Content-Language: en-GB

Live Demonstrates

Inspecting your HTTP Headers

To inspect the current configuration of your browser open this page created by André Schappo, http://co-project.lboro.ac.uk/users/coas/learn/http-request-header.php.

Demo 1: HTTP Headers, Credit André Schappo.

Language Adaptive Demo

Why not check out this demo page created again by André Schappo to demonstrate the principle of language adaptive PHP sites by reading HTTP Headers, http://co-project.lboro.ac.uk/users/coas/learn/language-adaptive.php

Demo 2: Language Adaptive Demo, Credit André Schappo.

Links

  1. http://www.google.com
  2. http://www.mozilla.org
  3. http://en.wikipedia.org/wiki/List_of_HTTP_headers
  4. http://en.wikipedia.org/wiki/HTTP_request
  5. André Schappo, Lecturer, Computer Science Department, Loughborough University
  6. http://co-project.lboro.ac.uk/users/coas/learn/http-request-header.php
  7. http://co-project.lboro.ac.uk/users/coas/learn/language-adaptive.php

This work is licenced under a Creative Commons Licence

A brief introduction

Matthew WitteringI am a graduate of Lougborough University where I read Computing and Management BSc (Hons) earning a 2:1 classification.

Currently I am working in the Product Team as a Junior Product Manager at Ask Jeeves UK. Continue