3 require_once 'HTMLPurifier/LanguageFactory.php';
5 class HTMLPurifier_Language
9 * ISO 639 language code of language. Prefers shortest possible version
14 * Fallback language code
16 var $fallback = false;
19 * Array of localizable messages
21 var $messages = array();
24 * Has the language object been loaded yet?
30 * Loads language object with necessary info from factory cache
31 * @note This is a lazy loader
34 if ($this->_loaded
) return;
35 $factory = HTMLPurifier_LanguageFactory
::instance();
36 $factory->loadLanguage($this->code
);
37 foreach ($factory->keys
as $key) {
38 $this->$key = $factory->cache
[$this->code
][$key];
40 $this->_loaded
= true;
44 * Retrieves a localised message. Does not perform any operations.
45 * @param $key string identifier of message
46 * @return string localised message
48 function getMessage($key) {
49 if (!$this->_loaded
) $this->load();
50 if (!isset($this->messages
[$key])) return '';
51 return $this->messages
[$key];