I'm building a website with multi-language support using geoplugin php class to detect country code. Here is my geolocate code:
//GEOLOCATE
$geoplugin = new geoPlugin();
$geoplugin->locate();
define('REAL_COUNTRY', strtoupper($geoplugin->countryCode));
//AVAILABLE COUNTRIES
function available_countries(){
$countries_array = array();
$sql = mysql_query("SELECT id FROM countries WHERE enabled = '1';") or die(mysql_error());
while($row = mysql_fetch_array($sql)) array_push($countries_array, $row['id']);
return $countries_array;
}
//RETURN COUNTRY CODE
function detect_language(){
if(isset($_COOKIE['country'])) return $_COOKIE['country'];
else if(isset($_SESSION['country'])) return $_SESSION['country'];
else if(in_array(REAL_COUNTRY, available_countries())) return REAL_COUNTRY;
else return 'EN';
}
Based on returned country code, my php script then loads content from database.
I want to have links formatted like this:
English site: sitename.com/contact
German site: sitename.com/kontakt
Slovenian site: sitename.com/kontakt
Notice, that URLs for German and Slovenian site are the same, but it still loads different content based on IP and returned code from geoplugin.
The site works well, but my concern are Google and other search engines. Will Google ever find pages in other languages than 'EN' or is it better to just use more classic approach and add a language id to URLs like this:
English site: sitename.com/en/contact
German site: sitename.com/de/kontakt
Slovenian site: sitename.com/si/kontakt
Thanks!