_loaded) return;
$factory = HTMLPurifier_LanguageFactory::instance();
$factory->loadLanguage($this->code);
foreach ($factory->keys as $key) {
$this->$key = $factory->cache[$this->code][$key];
}
$this->_loaded = true;
}
/**
* Retrieves a localised message.
* @param $key string identifier of message
* @return string localised message
*/
function getMessage($key) {
if (!$this->_loaded) $this->load();
if (!isset($this->messages[$key])) return "[$key]";
return $this->messages[$key];
}
/**
* Retrieves a localised error name.
* @param $int integer error number, corresponding to PHP's error
* reporting
* @return string localised message
*/
function getErrorName($int) {
if (!$this->_loaded) $this->load();
if (!isset($this->errorNames[$int])) return "[Error: $int]";
return $this->errorNames[$int];
}
/**
* Formats a localised message with passed parameters
* @param $key string identifier of message
* @param $args Parameters to substitute in
* @return string localised message
*/
function formatMessage($key, $args = array()) {
if (!$this->_loaded) $this->load();
if (!isset($this->messages[$key])) return "[$key]";
$raw = $this->messages[$key];
$substitutions = array();
foreach ($args as $i => $value) {
$substitutions['$' . $i] = $value;
}
return strtr($raw, $substitutions);
}
}
?>