[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/I18N/core/ -> MessageFormat.php (sommaire)

MessageFormat class file. This program is free software; you can redistribute it and/or modify it under the terms of the BSD License.

Author: Wei Zhuo
Version: $Revision: 1.5 $ $Date: 2005/08/27 03:21:12 $
Poids: 256 lignes (7 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

MessageFormat:: (8 méthodes):
  __construct()
  setCharset()
  getCharset()
  loadCatalogue()
  format()
  formatString()
  getSource()
  setUntranslatedPS()


Classe: MessageFormat  - X-Ref

MessageFormat class.

Format a message, that is, for a particular message find the
translated message. The following is an example using
a SQLite database to store the translation message.
Create a new message format instance and echo "Hello"
in simplified Chinese. This assumes that the world "Hello"
is translated in the database.

<code>
$source = MessageSource::factory('SQLite', 'sqlite://messages.db');
$source->setCulture('zh_CN');
$source->setCache(new MessageCache('./tmp'));

$formatter = new MessageFormat($source);

echo $formatter->format('Hello');
</code>

__construct(IMessageSource $source, $charset='UTF-8')   X-Ref
Constructor.
Create a new instance of MessageFormat using the messages
from the supplied message source.

param: MessageSource the source of translation messages.
param: string charset for the message output.

setCharset($charset)   X-Ref
Sets the charset for message output.

param: string charset, default is UTF-8

getCharset()   X-Ref
Gets the charset for message output. Default is UTF-8.

return: string charset, default UTF-8

loadCatalogue($catalogue)   X-Ref
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.

param: string message catalogue to load.

format($string,$args=array()   X-Ref
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();

param: string the string to translate.
param: array a list of string to substitute.
param: string get the translation from a particular message
param: string charset, the input AND output charset
return: string translated string.

formatString($string, $args=array()   X-Ref
Do string translation.

param: string the string to translate.
param: array a list of string to substitute.
param: string get the translation from a particular message
return: string translated string.

getSource()   X-Ref
Get the message source.

return: MessageSource

setUntranslatedPS($postscript)   X-Ref
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.

param: array first element is the prefix, second element the suffix.



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7