views:

55

answers:

3

I am making a multilingual Django website. I want the site to check from which country the user is accessing the website, and according to that decide which language to use.

What would be a good tool to use for that?

+1  A: 

When one of your regular users travels with his laptop to another country and access your site, can't understand a thing and can't change the language, that would suck.

I wouldn't recommend checking for the country (by IP probably). Instead go for the Accept-Language header the browser of the client sends. You should still leave the option to let the user change the language manually (and store the preference in the session for example).

Another option is going wikipedia style and setting the language by URL (en.example.com, de.example.com or example.com/en/, example.com/de/).

stefanw
I didn't say I'd be relying completely on the geolocation-- I intend to use some combination of that and `Accept-Language`. (And of course I'd let the user change.)I do not understand how the Wikipedia approach is useful, I am talking here about how to guess which language the user prefers.
cool-RR
+1  A: 

There is more than one way to do this, but a good solution is to use a geotargeting suite. Depending on your budget, there are free and paid solutions. I've used Digital Element's product (NetAcuity) for this type of thing in the past, and their solutions are top-notch. They provide both a in house server solution (for high-performance applications. ~30k queries per second) and a web-service solution for more typical applications. They have API's in numerous languages including Python that you could use within Django. They will allow you to query for information such as geo location, primary and secondary language, connection-speed, etc. all based on the users IP address. Geo accuracy at the the country level is highly accurate based on my experience.

A free solution to also consider is MaxMind, though I'm not as familiar with their product.

RC
+1  A: 

I had a similar problem on my site, and I used the MaxMind IP free database as a model and it's called as middleware.

So as the user goes to the site, the middleware detects his country by his IP and redirects him to the right language

Neytiri
nginx 0.7+ comes with a geoip module that sends the user's location data back in a set of headers. works quite well.
Carson