Class \Prado\I18N\core\MessageFormat
MessageFormat class.
Format a message, that is, for a particular message find the translated message. Create a new message format instance and echo "Hello" in simplified Chinese. This assumes that the word "Hello" is translated in the database.
// db1 must be already configured
$source = MessageSource::factory('Database', 'db1');
$source->setCulture('zh_CN');
$source->setCache(new MessageCache('./tmp'));
$formatter = new MessageFormat($source);
echo $formatter->format('Hello');
Class hierarchy
Author: Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
public
|
__construct(IMessageSource $source[, string $charset = 'UTF-8' ]) : mixed
Constructor.
Create a new instance of MessageFormat using the messages from the supplied message source. |
public
|
format(string $string[, array<string|int, mixed> $args = [] ][, null|string $catalogue = null ][, null|string $charset = null ]) : string
Format the string. That is, for a particular string find
the corresponding translation. Variable subsitution is performed
for the $args parameter. A different catalogue can be specified
using the $catalogue parameter.
The output charset is determined by $this->getCharset(); |
public
|
|
public
|
|
public
|
|
public
|
setUntranslatedPS(array<string|int, mixed> $postscript) : mixed
Set the prefix and suffix to append to untranslated messages.
e.g. $postscript=array('[T]','[/T]'); will output "[T]Hello[/T]" if the translation for "Hello" can not be determined. |
protected
|
formatString(string $string[, array<string|int, mixed> $args = [] ][, null|string $catalogue = null ]) : string
Do string translation.
|
protected
|
loadCatalogue(string $catalogue) : mixed
Load the message from a particular catalogue. A listed
loaded catalogues is kept to prevent reload of the same
catalogue. The load catalogue messages are stored
in the $this->message array.
|
|