Add i18n modules";
// Internal
$moduleConf = array();
echo 'add Module: Internal
' . print_r( $moduleConf, true ) . '
';
patI18n::addModule( 'Internal', $moduleConf );
// Gettext
$moduleConf = array(
'domain' => 'patI18n',
'domains' => array('patForms'),
'database' => 'pat',
'host' => 'localhost',
'user' => 'gerd',
'password' => 'gerd123',
'tablemsg' => 'i18nmsg',
'tabletrans'=> 'i18ntrans'
);
echo 'add Module: MySQL' . print_r( $moduleConf, true ) . '
';
if (isset($_GET['insert'])) {
echo "Insert Messaged
\n";
$m = patI18n::createModule('MySQL', $moduleConf);
/** @var $m patI18n_module:MySQL */
$id = $m->addMsg('Hello World!');
$m->addTranslation($id, 'Hallo Welt', 'de');
$id = $m->addMsg('Translate this massage using MySQL.');
$m->addTranslation($id, 'Übersetze diese Nachricht mit MySQL', 'de');
$id = $m->addMsg('Another message to translate with MySQL.');
$m->addTranslation($id, 'Eine weitere Nachricht die mit MySQL übersetzt wird', 'de');
$id = $m->addMsg('MySQL translate me, please!');
$m->addTranslation($id, 'MySQL, bitte übersetz mich', 'de');
$id = $m->addMsg('MySQL translate us, please!', $id);
$m->addTranslation($id, 'MySQL, bitte übersetz uns', 'de', 2);
exit(0);
}
patI18n::addModule('MySQL', $moduleConf);
echo "
";
echo "Set current locale
";
// set language to de_DE
patI18n::setLocale( 'de_DE' );
echo "
";
echo "Translate string of the default domain
";
echo patI18n::gettext('Translate this massage using MySQL.'), '
';
echo patI18n::gettext('Another message to translate with MySQL.'), '
';
echo patI18n::gettext('Sometimes there is no translation at all!' ), '
';
echo patI18n::ngettext('MySQL translate me, please!', 'MySQL translate us, please!', 1 ), '
';
echo patI18n::ngettext( 'MySQL translate me, please!', 'MySQL translate us, please!', 7 ), '
';
echo "
";
echo "Translate strings of patForms domain
";
echo patI18n::dgettext( 'patForms', 'patForms is translated in MySQL, as well' ), '
';
echo patI18n::dgettext( 'patForms', 'Some text in patForms are not translated in MySQL' ), '
';
echo patI18n::dngettext( 'patForms', 'There is one MySQL patForms validation error', 'There are some MySQL patForms validation errors', 1 ), '
';
echo patI18n::dngettext( 'patForms', 'There is one MySQL patForms validation error', 'There are some MySQL patForms validation errors', 7 ), '
';
?>