Location: PHPKode > scripts > Internationalization and Localization > internationalization-and-localization/database.php
<?php

require_once(dirname(__FILE__) . '/I18N.class.php');
require_once(dirname(__FILE__) . '/DatabaseConnection.class.php');

// Instantiate and set up the database handler class

$databaseConnection =& new DatabaseConnection();

$databaseConnection->setDbDriver('mysql');
$databaseConnection->setDbHost('localhost');
$databaseConnection->setDbUser('root');
$databaseConnection->setDbPassword('password');
$databaseConnection->setDbName('test');
$databaseConnection->setDbTablePrefix('');

$databaseConnection->open();

// Instantiate the source

$dataSource =& new DatabaseDataSource($databaseConnection);

// Do our I18N stuff

$i18n =& new I18N();

$i18n->setLanguage('en');
$i18n->setDataSource($dataSource);

$languages =& $i18n->fetchLanguages();
$container =& $i18n->fetch();
$section =& $i18n->fetch('section');
$element =& $i18n->fetch('section', 'element');

// Close our database connection

$databaseConnection->close();

// Print out results

echo '<b>ACTIVE LANGUAGES</b>';
echo '<hr />';
echo '<pre>';
print_r($languages);
echo '</pre>';
echo '<hr />';

echo '<b>CONTAINER</b>';
echo '<hr />';
echo '<pre>';
print_r($container);
echo '</pre>';
echo '<hr />';

echo '<b>SECTION</b>';
echo '<hr />';
echo '<pre>';
print_r($section);
echo '</pre>';
echo '<hr />';

echo '<b>ELEMENT</b>';
echo '<hr />';
echo '<pre>';
echo '<b>' . $element . '</b>';
echo '</pre>';
echo '<hr />';

?>
Return current item: Internationalization and Localization