Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CChoiceFormat
  • CDateFormatter
  • CDbMessageSource
  • CGettextMessageSource
  • CLocale
  • CMessageSource
  • CMissingTranslationEvent
  • CNumberFormatter
  • CPhpMessageSource
  • Overview
  • Package
  • Class
  • Tree

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
Extended by CApplicationComponent implements IApplicationComponent
Extended by CMessageSource
Extended by CDbMessageSource
Package: system\i18n
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
Methods summary
protected array
# loadMessages( string $category, string $language )

Loads the message translation for the specified language and category.

Loads the message translation for the specified language and category.

Parameters

$category
string
$category the message category
$language
string
$language the target language

Returns

array
the loaded messages
public CDbConnection
# getDbConnection( )

Returns the DB connection used for the message source.

Returns the DB connection used for the message source.

Returns

CDbConnection
the DB connection used for the message source.

Throws

CException
if CDbMessageSource::$connectionID application component is invalid

Since

1.1.5
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.

Loads the messages from database. You may override this method to customize the message storage in the database.

Parameters

$category
string
$category the message category
$language
string
$language the target language

Returns

array
the messages loaded from database

Since

1.1.5
Methods inherited from CMessageSource
getLanguage(), onMissingTranslation(), setLanguage(), translate(), translateMessage()
Methods inherited from CApplicationComponent
getIsInitialized(), init()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Constants summary
string CACHE_KEY_PREFIX 'Yii.CDbMessageSource.'
#
Properties summary
public string $connectionID 'db'
#

the ID of the database connection application component. Defaults to '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'.

the name of the source message table. Defaults to 'SourceMessage'.

public string $translatedMessageTable 'Message'
#

the name of the translated message table. Defaults to '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.

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.

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.

Properties inherited from CMessageSource
$forceTranslation
Properties inherited from CApplicationComponent
$behaviors
Magic properties summary
public CDbConnection $dbConnection
#

The DB connection used for the message source.

The DB connection used for the message source.

Magic properties inherited from CMessageSource
$language
Magic properties inherited from CApplicationComponent
$isInitialized
API documentation generated by ApiGen 2.8.0