Location: PHPKode > scripts > I18N class > i18n-class/example_SQL.php
<?php
$LocaleMechanism = 'SQL';
$nativeLocale = 'en_US';

include 'cnx_i18n.inc.php';
include_once 'rfc1766.class.php';
$oRfc1766 = new rfc1766_class;
$_SESSION['oRfc1766'] = $oRfc1766;
include_once 'i18n.class.php';
$oI18N = new I18N_class;
include_once 'langTable.class.php';


// The following parameters must be provided to the class: 
// host name, user, password, database name and table name.
// Modify the file cnx_i18n.inc.php.
$oLang = new LangTable_class($host,$user,$password,$db,$table);
$_SESSION['oLang'] = $oLang;

$oLang->OpenDb();
if(!$oLang->TableExists())
  $oLang->CreateTable();

if(isset($_POST['locale'])){
  setcookie('ex_SQL-locale',$_POST['locale'],time()+2592000); // This expiration time is 30 days.
  $locale = $_POST['locale'];
}elseif (isset($_COOKIE['ex_SQL-locale']))
  $locale = $_COOKIE['ex_SQL-locale'];
else
  $locale = $nativeLocale;

eval ($oI18N->XL('ExampleSQL', '$example', $locale));
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title><?=$example?></title>
</head>

<body>
<?
  eval ($oI18N->XL('SelectLang', '$selectLang', $locale));
  eval ($oI18N->XL('Submit', '$submitCap', $locale));
?>
  <h2><?=$example?></h2>
  <form name="example" method="post" enctype="multipart/form-data" action="example_SQL.php">
<?  $language = $oI18N->GetLocales(); ?>
    <?=$selectLang?>
    <select name="locale" tabindex="1">
<?
      foreach($language as $code => $name){
        if($code == $locale)
          print "<option selected=\"true\" value=\"$code\">$name</option>";
        else  
          print "<option value=\"$code\">$name</option>";
      } 
?>
    </select><br />
    <input name="submit" type="submit" value="<?=$submitCap?>" tabindex="2" />
  </form>
</body>
</html>
Return current item: I18N class