<?php /** * XMLTRANS EXAMPLE * * how to use it in your scripts (read this file before run it on your webserver) * * What you should do first: set the right paths for language files * (see $langarr in the first lines of class definition), set the default lang * and also set the temporary file path (used at update/delete key - $tempfile) */
// include the class file require_once('XMLTrans.class.php');
// create a new object $ob = new XMLTrans();
// get a translation from the files for english // 1 means echo, otherwise we should use echo $ob->XT_gettext('three', 'en', 0, XT_ATTR_MIN); // XT_ATTR_MIN means - the result is returned/echoed with all letters minuscules // there is also XT_ATTR_MAJ for majuscules $ob->XT_gettext('three', 'en', 1, XT_ATTR_MIN);
// as an admin, you want to update the value for a key // in this example we change the value for key 'two' with 'new value' $ob->XT_updatekey("new value", "two", "en");
// this will display the above value - 'new value' $ob->XT_gettext('two', 'en', 1);
// add a new key in romanian file $ob->XT_addkey('Patru', 'four', 'ro');
// add again the same key in romanian file; it returns FALSE $a = $ob->XT_addkey('Patru', 'four', 'ro'); var_dump($a); //false
// delete a key (two) from english file $ob->XT_deletekey('two', 'en');
// create a new empty language file // NOTE: for this moment, the references to files are hardcoded so, // you should put a reference to it in the class file $rez = $ob->XT_createfile('nl'); if ( $rez ) $ob->XT_addkey('Vijf', 'five', 'nl');
// List languages $langs = $ob->XT_list_languages(); var_dump($langs); // it returns something as array(3) { [0]=> string(2) "en" [1]=> string(2) "nl" ... }
?>
|