Hi!
There are two bugs in the Translation->init() method.
#1: The string value of Cache property is not casted to boolean. So if you set
Cache="false" the if condition results true because it's a not empty string.
#2: The Autosave property was not considered. Messages should only be saved
when this property is set to true.
Code:
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(TPropertyValue::ensureBoolean($config['cache']))//### FIX 1
$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']))//### FIX 2
{
Prado::getApplication()->attachEventHandler(
'OnEndRequest', array('Translation', 'saveMessages'));
$saveEventHandlerAttached=true;
}
}
}
Greetings
LCS
Original issue reported on code.google.com by rojaro@gmail.com on 2 Sep 2010 at 9:07
Original issue reported on code.google.com by
rojaro@gmail.com
on 2 Sep 2010 at 9:07