Class CDbMessageSource
CDbMessageSource represents a message source that stores translated messages in database.
The database must contain the following two tables:
CREATE TABLE SourceMessage ( id INTEGER PRIMARY KEY, category VARCHAR(32), message TEXT ); CREATE TABLE Message ( id INTEGER, language VARCHAR(16), translation TEXT, PRIMARY KEY (id, language), CONSTRAINT FK_Message_SourceMessage FOREIGN KEY (id) REFERENCES SourceMessage (id) ON DELETE CASCADE ON UPDATE RESTRICT );
The 'SourceMessage' table stores the messages to be translated, and the
'Message' table stores the translated messages. The name of these two tables can
be customized by setting CDbMessageSource::$sourceMessageTable
and CDbMessageSource::$translatedMessageTable
, respectively.
When CDbMessageSource::$cachingDuration
is set as a positive number, message
translations will be cached.
- CComponent
- CApplicationComponent implements IApplicationComponent
- CMessageSource
- CDbMessageSource
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.0
Located at x2engine/framework/i18n/CDbMessageSource.php
protected
array
|
#
loadMessages( string $category, string $language )
Loads the message translation for the specified language and category. |
public
|
|
protected
array
|
#
loadMessagesFromDb( string $category, string $language )
Loads the messages from database. You may override this method to customize the message storage in the database. |
getLanguage(),
onMissingTranslation(),
setLanguage(),
translate(),
translateMessage()
|
getIsInitialized(),
init()
|
string |
CACHE_KEY_PREFIX
|
'Yii.CDbMessageSource.' |
public
string
|
$connectionID | 'db' |
#
the ID of the database connection application component. Defaults to 'db'. |
public
string
|
$sourceMessageTable | 'SourceMessage' |
#
the name of the source message table. Defaults to 'SourceMessage'. |
public
string
|
$translatedMessageTable | 'Message' |
#
the name of the translated message table. Defaults to 'Message'. |
public
integer
|
$cachingDuration | 0 |
#
the time in seconds that the messages can remain valid in cache. Defaults to 0, meaning the caching is disabled. |
public
string
|
$cacheID | 'cache' |
#
the ID of the cache application component that is used to cache the messages. Defaults to 'cache' which refers to the primary cache application component. Set this property to false if you want to disable caching the messages. |
$forceTranslation
|
$behaviors
|
public
|
$dbConnection |
#
The DB connection used for the message source. |
$language
|
$isInitialized
|