83 $this->_loaded =
true;
93 if (!$this->_loaded) {
96 if (!isset($this->messages[
$key])) {
99 return $this->messages[
$key];
109 if (!$this->_loaded) {
112 if (!isset($this->errorNames[$int])) {
113 return "[Error: $int]";
115 return $this->errorNames[$int];
126 $sep_last = $this->
getMessage(
'Item separator last');
128 for (
$i = 0, $c = count($array);
$i < $c;
$i++) {
130 } elseif (
$i + 1 < $c) {
150 if (!$this->_loaded) {
153 if (!isset($this->messages[
$key])) {
156 $raw = $this->messages[
$key];
159 foreach ($args as
$i => $value) {
160 if (is_object($value)) {
164 $generator = $this->context->get(
'Generator');
166 if (isset($value->name)) {
167 $subst[
'$'.$i.
'.Name'] = $value->name;
169 if (isset($value->data)) {
170 $subst[
'$'.$i.
'.Data'] = $value->data;
172 $subst[
'$'.$i.
'.Compact'] =
173 $subst[
'$'.$i.
'.Serialized'] = $generator->generateFromToken($value);
177 if (!empty($value->attr)) {
178 $stripped_token = clone $value;
179 $stripped_token->attr =
array();
180 $subst[
'$'.$i.
'.Compact'] = $generator->generateFromToken($stripped_token);
182 $subst[
'$'.$i.
'.Line'] = $value->line ? $value->line :
'unknown';
185 } elseif (is_array($value)) {
186 $keys = array_keys($value);
189 $subst[
'$'.$i] = $this->
listify($value);
194 $subst[
'$'.$i.
'.Values'] = $this->
listify(array_values($value));
198 $subst[
'$' .
$i] = $value;
200 return strtr($raw, $subst);
Represents a language and defines localizable string formatting and other functions, as well as the localized messages for HTML Purifier.
$fallback
Fallback language code.
__construct($config, $context)
$messages
Array of localizable messages.
formatMessage($key, $args=array())
Formats a localised message with passed parameters.
$_loaded
Has the language object been loaded yet? bool.
$context
HTMLPurifier_Context
getErrorName($int)
Retrieves a localised error name.
$config
HTMLPurifier_Config
$code
ISO 639 language code of language.
static instance($prototype=null)
Retrieve sole instance of the factory.
$errorNames
Array of localizable error codes.
getMessage($key)
Retrieves a localised message.
Create styles array
The data for the language used.
Abstract base token class that all others inherit from.
listify($array)
Converts an array list into a string readable representation.
$error
True if no message file was found for this language, so English is being used instead.
load()
Loads language object with necessary info from factory cache.