views:

100

answers:

3

I don't want anything incredibly complicated. I am working on a client outside the US, and I just want a basic check to see if someone is accessing his page from the US or not. After that, I am going to default the language in either English or Spanish, after determining where the visitor is from.

Thanks.

+4  A: 

Why not use internationalization with php? it works based on users browser settings. I wouldn't like to see a different language just because I am in a different country ;-) I had tough time when Google started showing search results and options in French when I was in Paris for a short time.

Shoban
Yes, this is the right thing to do. Since you are only translating your content, not changing the actual content based on the user's locale. Google's situation is a little different, because they actually do localisation as well translation i.e. your search results in Paris will contain different sites, as well as being in French. I think they should try and be smarter about this, but many people have their operating system and browser set to en-US for compatability reasons or just because they can't change it - regardless of their lang/locale preferences.
Colin Pickard
Yeah, I found a site for that:http://www.thefutureoftheweb.com/blog/use-accept-language-headerIt kind of ducktales on what David Dorward said.
lucha libre
A: 

You can use a service like ip2location or you can just use this easier PHP technique to get locale information from the visitor.

Pablo Santa Cruz
I looked at that. I don't know. I'm not a big fan of using a lot of external sites and services, however, some other folks may be.
lucha libre
A: 

MaxMind gives away a free copy of their IP address location database. It's accurate enough for country specific. I'd suggest using the binary version though as it will be much faster than loading it in something like MySQL. They provide a PHP API in addition to more sophisticated methods.

But as others have said, IP address is a poor thing to set language on. If I'm traveling in Mexico and load your page with my browser that requests English you shouldn't be sending me Spanish simply because I'm in Mexico.

Jon Gales