PHP Classes

Classes of Dipl.-Ing.Sarah Schulze

Recommend this page to a friend!
  All class groups  >  All authors  >  Classes of Dipl.-Ing.Sarah Schulze (1)  >  Mission progress status  >  Reputation  
Picture of Dipl.-Ing.Sarah Schulze
Name: Dipl.-Ing.Sarah Schulze <contact>
Classes: 1
Country: Germany Germany
Age: 53
All time rank: 1965125 in Germany Germany
Week rank: 215 Up10 in Germany Germany Up
All time users: 1357
Week users: 0
 
  A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  
  Files folder image Translator  
A reimplementation of QT's Translator class.
usage:
1. a file named...example_function.php
2. its contents.....
<?php
/*! TRANSLATOR example_function.php */
function example_function(&$tr)
{
/*! searches only for a translation with in the context of "example_function.php" */
return $B = $tr->translate("example_function.php","This is a TEST");
}
?>

<?php
function example_function(&$tr)
{
/*! does the same than the version above, but searches the whole file for the corresponding translation. */
return $B = $tr->tr("This is a TEST");
}
?>

3. e.g. a main file.....main.php
4. its contents....
<?php
/*! TRANSLATOR main.php */
require_once(_INCLUDE_DIR."merlini18n.h");
require_once(_INCLUDE_DIR."example_function.php");

$tr = new Translator();
$tr->load("trans_".Translator::local(),"i18n/");
/*! sort of overloaded version. see doxygen docu.*/
$tr->load("trans_es.ts","i18n/");

/*! searches only for a translation with in the context of "main.php" */
$A = $tr->translate("main.php","main page");
$B = example_function($tr);

/*! does the same than the version above, but searches the whole file for the corresponding translation. */
$C = $tr->tr("main page");
........etc.
?>

5. the translation file.....trans_es.ts, made by lupdate.
6. its contents..
<!DOCTYPE TS><TS>
<context>
<name>main.php</name>
<message>
<source>main page</source>
<translation>pagina principal</translation>
</message>
</context>
<context>
<name>example_function.php</name>
<message>
<source>This is a TEST</source>
<translation>Esto es una prueba</translation>
</message>
</context>
</TS>

7. of course one can also use special characters inside the translation file following UTF-8.
8. Thats all for now.
Not enough user ratings


  A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z