| |||||||||||
| |||||||||||
Finding the language preference of a web site visitor
I can (and do) identify the country of origin of over 98% of the visitors to our web site using the maxmind database. But does that tell me what their native language is? No - it only gives me a clue.
A further clue is available from the accept-language header that's returned by browsers, and is available in PHP in the variable $_SERVER[HTTP_ACCEPT_LANGUAGE]. With this variable, your web site can check if the user has expressed a language preference (and perhaps given a second and third choice too), and you can use the information to tailor your response as appropriate. I've put up sample source code and a working demonstration on our web site. I've also added a page reporting language statistics for our own site ... only a very short data sample on there today, but as from tomoorow it will update daily with a 24 hour report. Some surpises ... I would expect to find most major European countries choosing their own langauges, with Swiss visitors choosing between German, Italian and English. The first tests I ran, though, gave me a series of pages called up from the USA with a first choice language of Korean. Truly, the world is a global market. (written 2006-06-18 07:17:31)
Associated topics are indexed under H112 - PHP - Further Web Page and Network HandlingA211 - Web Application Design and Deployment G902 - Well House Consultants - Web site techniques, utility and visibility
Some other Articles
From cat breeder to Cobol to PerlSplash! King Edward VII - days of empire Our new .eu top level domain Finding the language preference of a web site visitor Discounts and approved supplier lists Perl - turning seconds into days, hours, minutes and seconds Journey planning - Xephos v Transport Direct Much more that the world cup Huge data files - what happened earlier? 1638 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||