PClib demo site

<?php

/* project: TRANSLATOR, file: index.php */

/* Current language is stored in session. */
session_start();

//Include pclib framework
require 'pclib/pclib.php';

//Create pclib application
$app = new PCApp('demo');

$datasource 'pdo_mysql://user:password@localhost/test';

$app->db = new PCDb($datasource);

//Enable multilanguage support. We use variable $tr for convenience.
$tr = new PCTranslator('demo');

//Register translator as default application translator service.
$app->translator $tr;

//If you enable autoupdate, db-table will be filled with texts automatically.
//$tr->autoupdate = true;

//Set selected language
if ($_GET['lang']) $tr->language $_GET['lang'];


//Load texts in selected language. Text can be separated in pages, so you can
//load only texts which are needed. Texts are stored in db-table TRANSLATOR.
$tr->usePage('mlsdemo');

//You can translate texts in php code...
print $tr->translate('Text for translation.<br>');
print 
$tr->translate("Currently selected language: %s<br>" , array($tr->language) );
print 
$tr->translate("Language prefered by browser: %s<br>", array($tr->getClientLang()));

/* In template all labels are translated by default.
   And you can cover any multilanguage text in template with mls tag,
   so it will be tranlated too.
*/
$form = new PCForm('tpl/multilang.tpl');
if (
$form->submitted and $form->validate()) {
  
$app->message('Form has been sent.');
};
print 
$form;
?>

Elapsed time: 0.99 ms