25 public $keys = array(
'fallback',
'messages',
'errorNames');
57 public static function instance($prototype = null) {
58 static $instance = null;
59 if ($prototype !== null) {
60 $instance = $prototype;
61 }
elseif ($instance === null || $prototype ==
true) {
74 $this->dir = HTMLPURIFIER_PREFIX .
'/HTMLPurifier';
86 if ($code ===
false) {
87 $code = $this->validator->validate(
91 $code = $this->validator->validate($code,
$config, $context);
93 if ($code ===
false) $code =
'en';
95 $pcode = str_replace(
'-',
'_', $code);
101 $class =
'HTMLPurifier_Language_' . $pcode;
102 $file = $this->dir .
'/Language/classes/' . $code .
'.php';
103 if (file_exists(
$file) || class_exists($class,
false)) {
108 $fallback = $raw_fallback ? $raw_fallback :
'en';
111 if (!$raw_fallback) {
131 return $this->cache[$code][
'fallback'];
139 static $languages_seen = array();
142 if (isset($this->cache[$code]))
return;
145 $filename = $this->dir .
'/Language/messages/' . $code .
'.php';
148 $fallback = ($code !=
'en') ?
'en' :
false;
153 $filename = $this->dir .
'/Language/messages/en.php';
157 $cache = compact($this->keys);
164 if (isset($languages_seen[$code])) {
165 trigger_error(
'Circular fallback reference in language ' .
166 $code, E_USER_ERROR);
169 $language_seen[$code] =
true;
173 $fallback_cache = $this->cache[
$fallback];
176 foreach ( $this->keys as
$key ) {
177 if (isset(
$cache[$key]) && isset($fallback_cache[$key])) {
178 if (isset($this->mergeable_keys_map[$key])) {
180 }
elseif (isset($this->mergeable_keys_list[$key])) {
191 $this->cache[$code] =
$cache;