static function &factory($type, $source = '.', $filename = '')
{
$types = array('XLIFF', 'gettext', 'Database', 'SQLite');
if (empty($filename) && !in_array($type, $types)) {
throw new Exception('Invalid type "' . $type . '", valid types are ' . implode(', ', $types));
}
$class = 'MessageSource_' . $type;
if (empty($filename)) {
$filename = dirname(__FILE__) . '/' . $class . '.php';
}
if (is_file($filename) == false) {
throw new Exception("File {$filename} not found");
}
include_once $filename;
$obj = new $class($source);
return $obj;
}