Implements interfaces:
Abstract MessageSource class.
The base class for all MessageSources. Message sources must be instantiated using the factory method. The default valid sources are
- $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 MySQL message source, set the culture, set the cache handler, and use the source in a message formatter. The messages are store in a database named "messages". The source parameter for the actory method is a PEAR DB style DSN.
- $dsn = 'mysql://username:password@localhost/messages';
- $source = MessageSource::factory('MySQL', $dsn);
- //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);
Located in /I18N/core/MessageSource.php (line 72)
| Class | Description |
|---|---|
| MessageSource_gettext | MessageSource_gettext class. |
| MessageSource_MySQL | MessageSource_MySQL class. |
| MessageSource_SQLite | MessageSource_SQLite class. |
| MessageSource_XLIFF | MessageSource_XLIFF class. |
The translation cache.
The culture name for this message source.
Array of translation messages.
The source of message translations.
Add a untranslated message to the source. Need to call save() to save the messages to source.
Factory method to instantiate a new MessageSource depending on the
source type. The allowed source types are 'XLIFF', 'SQLite', 'MySQL', and 'gettext'. The source parameter is dependent on the source type. For 'gettext' and 'XLIFF', it should point to the directory where the messages are stored. For database types, e.g. 'SQLite' and 'MySQL', it should be a PEAR DB style DSN string.
Custom message source are possible by supplying the a filename parameter in the factory method.
Get all the variants of a particular catalogue.
This method must be implemented by subclasses.
Get the culture identifier for the source.
Get the last modified unix-time for this particular catalogue+variant.
Get the source, this could be a filename or database ID.
Determine if the source is valid.
Load a particular message catalogue. Use read() to to get the array of messages. The catalogue loading sequence is as follows
Load the message for a particular catalogue+variant.
This methods needs to implemented by subclasses.
Get the array of messages.
Set the cache handler for caching the messages.
Set the culture for this message source.
Documentation generated on Sun, 04 Jun 2006 18:58:28 -0400 by phpDocumentor 1.3.0RC4