My main language in my 4images gallery is Slovenian. What concern me that when visitor from outside my country come to my site, he/she will live it as soon as he/she will see that the site has strange language.
I would like that based on user IP (country) gallery language would change. If user is not (myip != SI) from Slovenia -> change to English language.
I've already installed GEO IP (from
http://www.maxmind.com/app/geoip_country) but I don't have idea how to automatically change language...
EDITED:
lol i think I found the way
Please someone test it first!
First you have to upload GEO IP files (Next few line taken from:
http://www.4homepages.de/forum/index.php?topic=7831.0)
Visit the home page of the tools will be used in this mod:
http://www.maxmind.com/app/geoip_countryRead the licence and make sure its NOT conflicts with your usage.
Download the following files:
1)
http://www.maxmind.com/download/geoip/api/php/geoip.incSave it in includes/ directory of your 4images installation
2)
http://www.maxmind.com/download/geoip/database/GeoIP.dat.gzExtract the content of this archive (u can use WinZIP, WinRAR, 7-Zip or any other archivers)
Save the extracted file (GeoIP.dat) into includes/ directory (make sure u keep the case: its GeoIP.dat not geoip.dat)
3)
http://www.maxmind.com/download/geoip/database/flag.zipor
http://web.tampabay.rr.com/vano/redirect.html?flags.zip4) Go to
global.php and before:
include_once(ROOT_PATH.'lang/'.$config['language_dir'].'/main.php');
add:
if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
if (!class_exists("GeoIP")) {
include(ROOT_PATH."includes/geoip.inc");
}
$gi = geoip_open(ROOT_PATH."includes/GeoIP.dat",GEOIP_STANDARD);
$countries = array();
$cid = geoip_country_code_by_addr($gi, $ip);
//$countries[$cid] = isset($countries[$cid]) ? $countries[$cid]+1 : 1;
if (strtolower($cid) == "hr") { // Croatian visitors
$config['language_dir'] = "hrvatski"; // change depend on secondary language
} elseif (strtolower($cid) == "si") { // visitors from my country Sloveniange
$config['language_dir'] = "slovenian"; // change depend on secondary language
} else { // all other visitors
$config['language_dir'] = "english"; //
}
Watch out! This is just my modification, because I have install in my 4images gallery three languages in those directories:
- slovenian
- english
- hrvatski
So depend on your installed languages change those line...
Please let me know if it's working or if you have any other suggestion.
You can check demo:
http://www.slo-foto.net/galerija