PHP 클래스 Prado\I18N\core\MessageSource

The base class for all MessageSources. Message sources must be instantiated using the factory method. The default valid sources are # XLIFF -- using XML XLIFF format to store the translation messages. # gettext -- Translated messages are stored in the gettext format. # Database -- Use an existing TDbConnection to store the messages. # SQLite -- (Deprecated) Store the translation messages in a SQLite database. A custom message source can be instantiated by specifying the filename parameter to point to the custom class file. E.g. $resource = '...'; //custom message source resource $classfile = '../MessageSource_MySource.php'; //custom message source $source = MessageSource::factory('MySource', $resource, $classfile); If you are writting your own message sources, pay attention to the loadCatalogue method. It details how the resources are loaded and cached. See also the existing message source types as examples. The following example instantiates a Database message source, set the culture, set the cache handler, and use the source in a message formatter. The messages are stored using an existing connection. The source parameter for the factory method must contain a valid ConnectionID. db1 must be already configured $source = MessageSource::factory('Database', 'db1'); set the culture and cache, store the cache in the /tmp directory. $source->setCulture('en_AU')l $source->setCache(new MessageCache('/tmp')); $formatter = new MessageFormat($source);
상속: implements Prado\I18N\core\IMessageSource
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$cache MessageCache The translation cache.
$culture string The culture name for this message source.
$messages array Array of translation messages.
$source string The source of message translations.
$untranslated

공개 메소드들

메소드 설명
append ( $message ) Add a untranslated message to the source. Need to call save() to save the messages to source.
factory ( $type, $source = '.', $filename = '' ) : MessageSource Factory method to instantiate a new MessageSource depending on the source type. The allowed source types are 'XLIFF', 'gettext' and 'Database'. The source parameter depends on the source type.
getCache ( ) : MessageCache Get the cache handler for this source.
getCulture ( ) : string Get the culture identifier for the source.
load ( $catalogue = 'messages' ) : boolean Load a particular message catalogue. Use read() to to get the array of messages. The catalogue loading sequence is as follows
read ( ) : array Get the array of messages.
setCache ( MessageCache $cache ) Set the cache handler for caching the messages.
setCulture ( $culture ) Set the culture for this message source.

보호된 메소드들

메소드 설명
getCatalogueList ( $catalogue ) : array Get all the variants of a particular catalogue.
getLastModified ( $source ) : integer Get the last modified unix-time for this particular catalogue+variant.
getSource ( $variant ) : string Get the source, this could be a filename or database ID.
isValidSource ( $source ) : boolean Determine if the source is valid.
loadData ( $variant ) : array Load the message for a particular catalogue+variant.

비공개 메소드들

메소드 설명
__construct ( ) Private constructor. MessageSource must be initialized using the factory method.

메소드 상세

append() 공개 메소드

Add a untranslated message to the source. Need to call save() to save the messages to source.
public append ( $message )

factory() 정적인 공개 메소드

For 'gettext' and 'XLIFF', 'source' should point to the directory where the messages are stored. For 'Database', 'source' must be a valid connection id. If a deprecated 'SQLite' type is used, 'source' must contain a valid DSN. Custom message source are possible by supplying the a filename parameter in the factory method.
static public factory ( $type, $source = '.', $filename = '' ) : MessageSource
리턴 MessageSource a new message source of the specified type.

getCache() 공개 메소드

Get the cache handler for this source.
public getCache ( ) : MessageCache
리턴 MessageCache cache handler

getCatalogueList() 보호된 메소드

This method must be implemented by subclasses.
protected getCatalogueList ( $catalogue ) : array
리턴 array list of all variants for this catalogue.

getCulture() 공개 메소드

Get the culture identifier for the source.
public getCulture ( ) : string
리턴 string culture identifier.

getLastModified() 보호된 메소드

Get the last modified unix-time for this particular catalogue+variant.
protected getLastModified ( $source ) : integer
리턴 integer last modified in unix-time format.

getSource() 보호된 메소드

Get the source, this could be a filename or database ID.
protected getSource ( $variant ) : string
리턴 string the resource key

isValidSource() 보호된 메소드

Determine if the source is valid.
protected isValidSource ( $source ) : boolean
리턴 boolean true if valid, false otherwise.

load() 공개 메소드

# [1] call getCatalogeList($catalogue) to get a list of variants for for the specified $catalogue. # [2] for each of the variants, call getSource($variant) to get the resource, could be a file or catalogue ID. # [3] verify that this resource is valid by calling isValidSource($source) # [4] try to get the messages from the cache # [5] if a cache miss, call load($source) to load the message array # [6] store the messages to cache. # [7] continue with the foreach loop, e.g. goto [2].
또한 보기: read()
public load ( $catalogue = 'messages' ) : boolean
리턴 boolean true if loaded, false otherwise.

loadData() 보호된 메소드

This methods needs to implemented by subclasses.
protected loadData ( $variant ) : array
리턴 array of translation messages.

read() 공개 메소드

Get the array of messages.
public read ( ) : array
리턴 array translation messages.

setCache() 공개 메소드

Set the cache handler for caching the messages.
public setCache ( MessageCache $cache )
$cache MessageCache

setCulture() 공개 메소드

Set the culture for this message source.
public setCulture ( $culture )

프로퍼티 상세

$cache 보호되어 있는 프로퍼티

The translation cache.
protected MessageCache,Prado\I18N\core $cache
리턴 MessageCache

$culture 보호되어 있는 프로퍼티

The culture name for this message source.
protected string $culture
리턴 string

$messages 보호되어 있는 프로퍼티

Array of translation messages.
protected array $messages
리턴 array

$source 보호되어 있는 프로퍼티

The source of message translations.
protected string $source
리턴 string

$untranslated 보호되어 있는 프로퍼티

protected $untranslated