PHP Classes

File: xml.php

Recommend this page to a friend!
  Classes of Mariano Iglesias   Internationalization and Localization   xml.php   Download  
File: xml.php
Role: Example script
Content type: text/plain
Description: This script presents an example of using the I18N package with XML files as its source of data
Class: Internationalization and Localization
Get internationalized texts from databases or XML
Author: By
Last change:
Date: 18 years ago
Size: 937 bytes
 

Contents

Class file image Download
<?php

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

// Instantiate the source

$dataSource =& new XmlDataSource(dirname(__FILE__) . '/xml/i18n-xml.xml');

// 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');

// 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 />';


?>