/**
* Initialize the TTranslate translation components
*/
public static function init($catalogue = 'messages')
{
static $saveEventHandlerAttached = false;
//initialized the default class wide formatter
if (!isset(self::$formatters[$catalogue])) {
$app = Prado::getApplication()->getGlobalization();
$config = $app->getTranslationConfiguration();
$source = MessageSource::factory($config['type'], $config['source'], $config['filename']);
$source->setCulture($app->getCulture());
if (isset($config['cache'])) {
$source->setCache(new MessageCache($config['cache']));
}
self::$formatters[$catalogue] = new MessageFormat($source, $app->getCharset());
//mark untranslated text
if ($ps = $config['marker']) {
self::$formatters[$catalogue]->setUntranslatedPS(array($ps, $ps));
}
//save the message on end request
// Do it only once !
if (!$saveEventHandlerAttached && TPropertyValue::ensureBoolean($config['autosave'])) {
Prado::getApplication()->attachEventHandler('OnEndRequest', array('Translation', 'saveMessages'));
$saveEventHandlerAttached = true;
}
}
}