Welcome Guest, Not a member yet? Register   Sign In
IP tracking help
#4

[eluser]xwero[/eluser]
Which 5% did you understand Smile

CIs user agent library gets the string from the browser that gets send along with the http request.
Quote:Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.4) Gecko/20060613 Camino/1.0.2
As you can see the language string is embedded (en-US) and with the method accept_lang you can find out if the language you offer exist in the user agent string.
Code:
$langs = array('en','nl','es');
$setlanguage = '';
foreach($langs as $lang)
{
   if($this->agent->accept_lang($lang)){ $setlang = $lang; exit; }
}
if($setlang == '')
{
   // default language
}
else
{
  // set fetched language
}
This is a more correct way than getting the country and selecting the language based on a country because there are more than one country that have different language areas and you don't know if the viewer of your site is indeed from that country or some traveller who connects his own pc in that country, he could have an whole other language than those spoken in the country.


Messages In This Thread
IP tracking help - by El Forum - 01-28-2008, 09:44 AM
IP tracking help - by El Forum - 01-28-2008, 09:50 AM
IP tracking help - by El Forum - 01-28-2008, 10:27 AM
IP tracking help - by El Forum - 01-28-2008, 10:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB