geoip_lang

Component ID

2013815

Component name

geoip_lang

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

This module allows you to use free GeoIP Lite database by MaxMind to redirecting users based on their country or location for an i18n site
For using this module geoip should be insatlled on your webserver .

$ sudo -s
# apt-get install build-essential php5-dev php5-cli libgeoip-dev libgeoip1 php-pear
# pecl install geoip

Next

# echo "extension=geoip.so" >> /etc/php5/cli/php.ini
# echo "extension=geoip.so" >> /etc/php5/apache2/php.ini
# wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# gunzip GeoLiteCity.dat.gz
# mv GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

to test use this code

var_dump(geoip_record_by_name('209.202.168.22'));

The Logic

Basically this module tests to see

  • If you have a writable session.
  • If you have already been redirected.
  • Which country you are in.
  • If the URL you requested already has a country code.
  • Which languages are provided for on the site.

This project is inspired by this tutorial.

What this module do ?

  1. Detect the user location
  2. Browse country database for checking out the user language
  3. Redirect to the right language if it's enabled by i18n and the user are not already redirected to it
  4. If the user was alreday redirected and he pick another language he will be not redirected another time