<?
 
include "HTTPLocale.class.php";
 
 
/*
 
Q: I would like to know how to use it with gettext(), since it needs values such as ru_RU, en_US, en_AU, en, pl....etc
 
A: you can do like this (see below)
 
*/
 
 
class PHPLocalizator extends HTTPLocale
 
{
 
  var $php_locale;
 
  function PHPLocalizator()
 
  {
 
    parent::HTTPLocale();
 
    $this->php_locale = strtolower($this->language) . ( empty($this->country) ?  '' : '_'.$this->country );
 
  }
 
}
 
$locale = new PHPLocalizator();
 
 
?>
 
<html>
 
  <head>
 
    <title>HTTPLocale usage example</title>
 
  </head>
 
  
 
  <body>
 
  <br/><br/>
 
    Your browser language is <?=$locale->language?><br/>
 
    Your browser country is <?=( empty($locale->country) ?  '[not defined]' : $locale->country );?> <hr/>
 
    Your PHP locale is <?=$locale->php_locale?> <hr/>
 
  </body>
 
</html>
 
 |