The request header of the HTTP GET method can contain a parameter named “Accept-Language”. The value of that parameter specifies a list of languages acceptable by the client browser. For example, Firefox 3.5 sends the following during a request:
Accept-Language: en-gb,en;q=0.5
The above line tells the server “I prefer British English language over American English”. This doesn’t reflect my personal taste of course, but I doubt there are servers that differentiate between the two variations.
Languages are defined by using their international language codes. Multiple languages must be separated by comma and a single space. The “;q=0.5” sub-parameter is a weight, used to sort the languages in order of importance (highest weight first). By default, weight equals 1.0 .
In PHP, you can get the value of the “Accept-Language” parameter from the $_SERVER array.
For multi-language websites, the simplest way to decide which language to use is to compare two arrays, one with the list of supported languages and the other with the user’s preferred languages.
