25 public $keys =
array(
'fallback',
'messages',
'errorNames');
59 public static function instance($prototype = null)
61 static $instance = null;
62 if ($prototype !== null) {
63 $instance = $prototype;
64 } elseif ($instance === null || $prototype ==
true) {
78 $this->dir = HTMLPURIFIER_PREFIX .
'/HTMLPurifier';
91 if (
$code ===
false) {
92 $code = $this->validator->validate(
100 if (
$code ===
false) {
104 $pcode = str_replace(
'-',
'_',
$code);
110 $class =
'HTMLPurifier_Language_' . $pcode;
111 $file = $this->dir .
'/Language/classes/' .
$code .
'.php';
112 if (file_exists(
$file) || class_exists($class,
false)) {
117 $fallback = $raw_fallback ? $raw_fallback :
'en';
120 if (!$raw_fallback) {
139 return $this->cache[
$code][
'fallback'];
148 static $languages_seen =
array();
151 if (isset($this->cache[
$code])) {
156 $filename = $this->dir .
'/Language/messages/' . $code .
'.php';
159 $fallback = ($code !=
'en') ?
'en' :
false;
164 $filename = $this->dir .
'/Language/messages/en.php';
168 $cache = compact($this->keys);
175 if (isset($languages_seen[$code])) {
177 'Circular fallback reference in language ' .
183 $language_seen[
$code] =
true;
187 $fallback_cache = $this->cache[
$fallback];
190 foreach ($this->keys as
$key) {
191 if (isset(
$cache[$key]) && isset($fallback_cache[$key])) {
192 if (isset($this->mergeable_keys_map[$key])) {
194 } elseif (isset($this->mergeable_keys_list[$key])) {
Represents a language and defines localizable string formatting and other functions, as well as the localized messages for HTML Purifier.
getFallbackFor($code)
Returns the fallback language for language.
Validates the HTML attribute lang, effectively a language code.
$keys
Valid keys in the HTMLPurifier_Language object.
$validator
Instance to validate language codes.
loadLanguage($code)
Loads language into the cache, handles message file and fallbacks.
$cache
Cache of language code information used to load HTMLPurifier_Language objects.
static instance($prototype=null)
Retrieve sole instance of the factory.
setup()
Sets up the singleton, much like a constructor.
Create styles array
The data for the language used.
create($config, $context, $code=false)
Creates a language object, handles class fallbacks.
$dir
Cached copy of dirname(FILE), directory of current file without trailing slash.
$mergeable_keys_map
Keys whose contents are a hash map and can be merged.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
Class responsible for generating HTMLPurifier_Language objects, managing caching and fallbacks...
$mergeable_keys_list
Keys whose contents are a list and can be merged.