Reply LinkBack Thread Tools Search this Thread
Old 31-01-2008, 15:19   #1 (permalink)
Tintin81
Registered User
 
Join Date: Jan 2008
Location: Hamburg, Germany
Posts: 27
What's the BEST way to detect the browser language?

Hi,

I have a website in two languages, English and German:

How can I make sure that each visitor is sent to the correct language version? I've been doing quite a bit of searching but can't decide between a javascript or php based solution.

I need a script that detects the user's browser language and then immediately renders the website in his/her language. However, the user should also be given the opportunity to switch to the other language should s/he wish to.

Any ideas on how to implement this?
  Reply With Quote
Old 31-01-2008, 16:06   #2 (permalink)
proc355
Trailer Trash™
 
proc355's Avatar
 
Join Date: Sep 2006
Posts: 851
server-side, Accept-Language header
__________________
meh.
  Reply With Quote
Old 31-01-2008, 18:37   #3 (permalink)
haku
shiro
 
haku's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 1,815
  Reply With Quote
Old 01-02-2008, 05:51   #4 (permalink)
MikeMackay
Everything is fine.
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Witham & London
Posts: 744
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
For this situation I would try to avoid a JavaScript solution as this can easily be disabled thereby rendering your language detection obsolete. Using a server-side solution you should always get the result you require; a more reliable method.

- Mike
  Reply With Quote
Old 01-02-2008, 07:49   #5 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,465
This is one of my pet hates. When you're an expat using Japanese Windows, it's an absolute pain in the ass to keep switching to English - you'd be amazed how many sites auto-detect language these days. It's one of the main reasons I use a Mac, because the language setting is switchable between accounts - my wife can have everything in Japanese and I can use English.

Now, that said, it's a completely sensible thing to do, because it does provide a service for the vast majority, and only inconveniences a tiny minority of people. But as a member of that tiny minority, can I plead with you to bear in mind the following:

1. make it ABSOLUTELY BLOODY CLEAR, where to change the language settings. There's nothing worse than having to hunt through half the site trying to find out how to switch it to your language of choice, because the designer buried it somewhere. If I'm only there for a quick visit, I'll use Japanese because sometimes it's not worth the hassle of switching, but a lot of my web surfing is for relaxation or my own personal interests, and I'd like to be able to do that in my native language where possible.

2. Set a cookie with a long expiration time to remember the language settings. It's really annoying when you go back to a site regularly and have to switch the language every single time you use it.
  Reply With Quote
Old 01-02-2008, 07:53   #6 (permalink)
herkalees
Semantics, yay.
 
herkalees's Avatar
 
Join Date: Nov 2005
Location: Salem, Massachusetts
Posts: 1,088
That's a priceless substitute for user-research right there ↑
__________________
  Reply With Quote
Old 01-02-2008, 08:15   #7 (permalink)
haku
shiro
 
haku's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 1,815
Shit, I didnt even realize that you could switch it to English! I always just end up reading the sites in Japanese!
My home PC is English though, so its only an issue when Im at work.
  Reply With Quote
Old 01-02-2008, 08:32   #8 (permalink)
Tintin81
Registered User
 
Join Date: Jan 2008
Location: Hamburg, Germany
Posts: 27

Quote:
Originally Posted by Hunch
1. make it ABSOLUTELY BLOODY CLEAR, where to change the language settings. There's nothing worse than having to hunt through half the site trying to find out how to switch it to your language of choice, because the designer buried it somewhere. If I'm only there for a quick visit, I'll use Japanese because sometimes it's not worth the hassle of switching, but a lot of my web surfing is for relaxation or my own personal interests, and I'd like to be able to do that in my native language where possible.

2. Set a cookie with a long expiration time to remember the language settings. It's really annoying when you go back to a site regularly and have to switch the language every single time you use it.

Hi Hunch,

This is exactly what I'm planning to do. I have myself lived abroad for a few years, so I know EXACTLY what you're talking about here. On all of my pages there will be a language switch button in the upper right corner, so users can select another language at any time. I think this is indeed very important from a usability point of view.

Nonetheless, the first time somebody visits my site, it should appear in the respective system language and not some generic default language, that is, when the user has "German" as his system language, the site should appear in German, in all other instances it should appear in English.

How can I do this? Would you reckon that a PHP-based solution is best? Thanks for any input in this matter... Cheers.
  Reply With Quote
Old 01-02-2008, 09:39   #9 (permalink)
Hunch
Grumpy old man
 
Hunch's Avatar
 
Join Date: Oct 2007
Location: North Japan
Posts: 1,465
This looks interesting. Requires the PHP HTTP extension.

PHP.net: http_negotiate_language - Manual
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8