How To Make Your Web Site Respond To Browser Language Requests.

There are four steps:

How does the web browser make a request for specific languages?

The browser writes a value for the Accept-Language request header field that it sends to the web server. You can set this value in Preferences (Netscape) or Internet Options (Internet Explorer). If you choose multiple languages, they are sent to the server as a comma-delimited list in your preferred order.

With the settings above, the request header field will be Accept-Language = de,en-us,it,fr,pt-br,es.

How does the web server determine which language to serve? Is there a naming convention for multi-lingual web pages?

Deciding which page to serve is called content negotiation.

Tim Berners-Lee's discussion of generic web pages and their language variants describes two different naming conventions, index.fr.html and index.html.fr.

The Apache Web Server 2.0 compiles in content negotiation (the mod_negotiation module) by default. It postpends the two-letter language code to the URL and looks for files to serve.

For example, if you set your browser preferred language to French and browse to http://www.openinternetlexicon.com, an Apache server would look for the file www.openinternetlexicon.com/index.html.fr.

Unfortunately, postfixing the language code is not as desirable as infixing it - index.fr.html - which allows the server's operating system to use a familiar extension. The Apache docs on content negotiation say that you can choose between naming conventions, because files can have more than one extension, and the order of the extensions is normally irrelevant (see mod_mime documentation for details). We suggest infixing the language (and other) variants.

Microsoft Internet Information Server negotiates language with an optional ISAPI filter. There does not appear to be a standard ISAPI filter for language negotiation on the market.

Server-driven Negotiation (W3C HTTP/1.1 spec RFC2616 Section 12.1)

If the selection of the best representation for a response is made by an algorithm located at the server, it is called server-driven negotiation. Selection is based on the available representations of the response (the dimensions over which it can vary; e.g. language, content-coding, etc.) and the contents of particular header fields in the request message or on other information pertaining to the request (such as the network address of the client).

Server-driven negotiation is advantageous when the algorithm for selecting from among the available representations is difficult to describe to the user agent, or when the server desires to send its "best guess" to the client along with the first response (hoping to avoid the round-trip delay of a subsequent request if the "best guess" is good enough for the user). In order to improve the server's guess, the user agent MAY include request header fields (Accept, Accept-Language, Accept-Encoding, etc.) which describe its preferences for such a response.

Do web servers handle multi-lingual requests automatically?

Not normally. The web server must have multiple language versions of a web page in order to serve them. It needs to know how the language-variant web pages are named. Besides naming them with a URI (index.fr.html), it may be possible to transmit the language variance as metadata in the HTTP header. This is the direction of the WebDAV protocol being developed by the IETF.

PlanetarySales.com offers an ASP or Java component ($499) that allows a web server to respond with a page in the language that the browser requests. But this can be done on the server with Active Server Pages (ASP), or with JSP, PHP, or Perl, as this site shows.

What are some example sites that serve multi-lingual pages? Do they recognize the browser language request?

There are many multi-lingual sites, but most ask you to choose your language from their home page. Few respond to your browser settings for a preferred language. Google, the search engine, does, and in several languages. Another is Alis Technologies (only in French and English). planetarySales.com responds to requests for English, German, and Japanese.
An Apache 2.0 web server default installation supports several languages. Your browser must be set to a non-English language to see these work.

Do you know of some exemplary multilingual sites that we should list? Send us their URLs.

 
Criticisms? Suggestions?   Do you want us to add a reference or hyperlink to this page? Send us an email or add a comment directly to this page below. Back to top of OIL site.