- From: Richard Ishida <ishida@w3.org>
- Date: Wed, 23 Jul 2003 14:49:53 +0100
- To: <public-i18n-geo@w3.org>
-----Original Message----- From: Lloyd Honomichl [mailto:lloyd@mail.honomichl.com] Sent: 23 July 2003 00:47 To: ishida@w3.org Subject: A Q&A I'm away from home and my mail connection is fragile, but here it is. Can you forward it as needed? Question: What are the pitfalls of using the HTTP Accept Language header to determine the locale of the user? Background: For a number of perfectly valid reasons some web applications would like to associate a locale with each user that visits the site. Some of the information this locale might ideally provide are: . What is the user's time zone? . What currency symbols and formats does the user expect? . How should date's and time's be formatted? . Should measurements be metric (centimeters, kilometers, liters) or imperial (inches, miles, gallons)? . Does the user use letter/legal size paper, or A4 . What shoe and clothing sizing systems should be used? . What is the user's physical location? Since none of these are included in the HTTP protocol many web developers have used the Accept-Language header to make inferences about the user's locale. Answer: Using the Accept-Language header is a reasonable approach as long as you know its limitations and give the user some way to override the assumptions you make. Accept-language is ONLY intended for language use. If you use Accept- Language exclusively, you may handcuff the user into a set of choices not to his liking. Many users never change the defaults for Accept-Language. They are set when the user agent is installed. Unless they are multilingual or have some other reason to adjust language preferences they may not even know such settings exist. Hence, the user may not have ever ratified the Accept-Language setting. A user agent may send a request that specifies only a language and not a region, for example you may not get a header with "de_DE", "de_SW" or "de-AT" to indicate German as spoken in Germany, Switzerland or Austria. You might only get "de" indicating a preference for German. If you were planning to use the region to decide what currency to use you are now in a bind. Your particular circumstances might allow you to make assumptions such as "Germany has 83 million people, Switzerland has 7 million but only 63% speak German, Austria has 8 million, so this user probably uses the Euro. If we're wrong we'll only offend 4.6% of our German speaking customers or just over 4 million people." Feel free to make such an assumption, if you can accept the risk. Its a lot simpler to ask the user for more information. Also, the math gets lots harder for Spanish. People borrow machines from friends, they rent them from internet cafes. Do you want to shove Polish content at a user just because they are running a user agent in Warsaw? Some of the language selection mechanisms in Apache requires an exact match to the Accept-Language header. If a set of documents exists for fr_CA and fr_FR then a request for a document matching just "fr" may fail with a error. This may not be a problem for your web site, but if they have to specify the region for your web page to work correctly, they may have problems with other web sites that expect only language. To satisfy both they'd have to configure their user agent to send both "fr" and "fr_CA". In short: for a first contact using the Accept-Language to infer regional settings is a good starting point, but be sure to allow them to specify their cultural settings more exactly. Store the results in database or a cookie for later visits.
Received on Wednesday, 23 July 2003 09:50:37 UTC