Set language based on IP

Hi all, I have a project with anonymous users enabled. On opening of the homepage I would like users to be redirected based on their IP (or even better, set their language based on their country, derived from the IP address). I would like to avoid having to create a request handler for this, because I already use the deep link module as well and I expect this to complicate things. Besides, having multiple request handlers would probably result in the loading of multiple pages which is visible for the end user. The hardest part for me is finding out from which IP address the user approaches the website. I found some answers on the forum, but they all involve creating request handlers. Tips and ideas are welcome!
2 answers

You could use Nikel's suggestion, this is the quick/easy way. You would just add an additional parameter in the url to automatically assign a language.

For another customer I created a module to review the user's browser language (based on the supported language flag in the browser). That customer expressed the same need as you are, but they wanted to allow any anonymous user to switch languages even without deeplinks.

The module allows you to place a snippet in your layout, this snippet contains a widget that checks the browser language and can either present the user with a message and let him choose to switch, or automatically redirects to the same language as the browser.

This is the module I was referring to.


Modifying the existing deeplink module's requestHandler should not be hard. You would ofcourse lose the possibility to do a simple upgrade for the module later on.

I would think the real challenge is having a good database with ip's addresses mapped to languages, but haven't ever looked into this.

By the way, isn't the best practice to use the accepted language header sent by the user's browser for this?