$source = MessageSource::factory('SQLite', 'sqlite://messages.db');
$source->setCulture('zh_CN');
$source->setCache(new MessageCache('./tmp'));
$formatter = new MessageFormat($source);
echo $formatter->format('Hello');
Показать файл
Открыть проект
Свойство | Тип | Описание | |
---|---|---|---|
$Catalogue | string | Set the default catalogue. |
Свойство | Тип | Описание | |
---|---|---|---|
$catagloues | array | A list of loaded message catalogues. | |
$charset | string | Output encoding charset | |
$messages | array | The translation messages. | |
$postscript | array | The prefix and suffix to append to untranslated messages. | |
$source | The message source. | ||
$untranslated | array | A list of untranslated messages. |
Метод | Описание | |
---|---|---|
__construct ( Prado\I18N\core\IMessageSource $source, $charset = 'UTF-8' ) | Constructor. | |
format ( $string, $args = [], $catalogue = null, $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. | |
getCharset ( ) : string | Gets the charset for message output. Default is UTF-8. | |
getSource ( ) : |
Get the message source. | |
setCharset ( $charset ) | Sets the charset for message output. | |
setUntranslatedPS ( $postscript ) | Set the prefix and suffix to append to untranslated messages. |
Метод | Описание | |
---|---|---|
formatString ( $string, $args = [], $catalogue = null ) : string | Do string translation. | |
loadCatalogue ( $catalogue ) | 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. |
public __construct ( Prado\I18N\core\IMessageSource $source, $charset = 'UTF-8' ) | ||
$source | Prado\I18N\core\IMessageSource |
protected formatString ( $string, $args = [], $catalogue = null ) : string | ||
Результат | string | translated string. |
public getCharset ( ) : string | ||
Результат | string | charset, default UTF-8 |
public getSource ( ) : |
||
Результат |
protected loadCatalogue ( $catalogue ) |
public setUntranslatedPS ( $postscript ) |
protected array $catagloues | ||
Результат | array |
protected array $postscript | ||
Результат | array |
protected MessageSource,Prado\I18N\core $source | ||
Результат |
protected array $untranslated | ||
Результат | array |