#227

Product support

Get help in the plugin support forum.

Categories

  • Miscellaneous
  • Utility

GeoLocale Switcher

Version ready for Laravel 5.5 is ready and will be provided shortly.

Features

This is a simple plugin that automatically detects the country of the visitor and switch the website to appropriate language (basing on the iso code). If there is no language for given country - default language is triggered. If the visitor switches the language, the decision is remembered.

Latest version includes special component for multilingual countries.

By default, it uses free IP database (mmdb format).

Any suggestions about development of this plugin are highly welcome.

GeoLocaleSwitcher

About

Plugin usage is very simple. Install it and go to Settings -> GeoLocaleSwitcher to enable it.

When enabled in settings, plugin forwards the visitor to appropriate language version of the website, basing on the detected location:

For example: website.com has 3 languages: English, German and French.

  • When visitor from Germany is detected, plugin redirects her/him to website.com/de
  • When visitor from French is detected, plugin redirects her/him to website.com/fr
  • When visitor from United States, Poland or China is detected, plugin triggers website.com in default language (/en).

Database

Database is stored in keios/geolocaleswitcher/database/database.mmdb. It has Creative Commons Attribution-ShareAlike 3.0 Unported License. You can change it to any compatible mmdb geolocation database you want, we will never upgrade this part of the plugin.

Link to the details of the database: http://dev.maxmind.com/geoip/legacy/geolite/

Components

There are two components attached to this plugin.

GeoLocaleSwitcher Component

It is simple component that displays detected county and current locale (eg United States - English) and links to page set up in Component Properties as Language Change Page.

It provides you with {{ location }} array in your Twig. This array includes following variables:

[
  "ip"          => Detected visitor's IP address
  "isoCode"     => Detected country ISO
  "country"     => Detected country name
  "city"        => Detected city
  "state"       => Detected state ISO
  "postal_code" => Detected postal code
  "lat"         => Detected latitude
  "lon"         => Detected longitude
  "timezone"    => Detected timezone
  "continent"   => Detected continent
  "prefix"      => Phone prefix for detected country
]

You can access these variables from Twig by calling for example {{ location['country'] }} Please keep in mind that visitors public IPs are given by ISP and data like postal_code or city will very rarely be true.

LocaleAsk Component

This component is for multilanguage countries. It takes data from GeoLocaleRepository class, checks available languages for detected country and display them.

For example your website has three language versions: English, Spanish and French. For visitors from France, component will display only link to French locale, for visitors from USA, it will display English and Spanish and for visitors from Canada, it will display English and French.

You may want to use this component and LocalePicker component from Rainlab Translate to provide your visitors fully featured language change page.

More

Check demo of this plugin at demo.keios.eu!

Note

If you find this free plugin not useful because we didn't write examples that you could copy/paste into your paid projects or you are too lazy to read brain-dead simple component's source code - please kindly do not use it.

1.3.0

LocaleAsk Component

Oct 01, 2015

1.2.0

Settings added to enable or disable redirect

Oct 01, 2015

1.1.0

Refactor to Keios and upgrade for OctoberCMS RC

Mar 16, 2015

1.0.1

First version of GeoLocaleSwitcher

Jan 22, 2015