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 CMessageSource

CMessageSource is the base class for message translation repository classes.

A message source is an application component that provides message internationalization (i18n). It stores messages translated in different languages and provides these translated versions when requested.

A concrete class must implement CMessageSource::loadMessages() or override CMessageSource::translateMessage().

CComponent
Extended by CApplicationComponent implements IApplicationComponent
Extended by CMessageSource

Direct known subclasses

CDbMessageSource, CGettextMessageSource, CPhpMessageSource, X2MessageSource
Abstract
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/CMessageSource.php
Methods summary
abstract 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 string
# getLanguage( )

Returns

string
the language that the source messages are written in. Defaults to CApplication::language application language.
public
# setLanguage( string $language )

Parameters

$language
string
$language the language that the source messages are written in.
public string
# translate( string $category, string $message, string $language = null )

Translates a message to the specified language.

Translates a message to the specified language.

Note, if the specified language is the same as the getLanguage source message language, messages will NOT be translated.

If the message is not found in the translations, an CMessageSource::onMissingTranslation() event will be raised. Handlers can mark this message or do some default handling. The CMissingTranslationEvent::$message property of the event parameter will be returned.

Parameters

$category
string
$category the message category
$message
string
$message the message to be translated
$language
string
$language the target language. If null (default), the CApplication::getLanguage application language will be used.

Returns

string
the translated message (or the original message if translation is not needed)
protected string
# translateMessage( string $category, string $message, string $language )

Translates the specified message. If the message is not found, an CMessageSource::onMissingTranslation() event will be raised.

Translates the specified message. If the message is not found, an CMessageSource::onMissingTranslation() event will be raised.

Parameters

$category
string
$category the category that the message belongs to
$message
string
$message the message to be translated
$language
string
$language the target language

Returns

string
the translated message
public
# onMissingTranslation( CMissingTranslationEvent $event )

Raised when a message cannot be translated. Handlers may log this message or do some default handling. The CMissingTranslationEvent::$message property will be returned by CMessageSource::translateMessage().

Raised when a message cannot be translated. Handlers may log this message or do some default handling. The CMissingTranslationEvent::$message property will be returned by CMessageSource::translateMessage().

Parameters

$event
CMissingTranslationEvent
$event the event parameter
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()
Properties summary
public boolean $forceTranslation false
#

whether to force message translation when the source and target languages are the same. Defaults to false, meaning translation is only performed when source and target languages are different.

whether to force message translation when the source and target languages are the same. Defaults to false, meaning translation is only performed when source and target languages are different.

Since

1.1.4
Properties inherited from CApplicationComponent
$behaviors
Magic properties summary
public string $language
#

The language that the source messages are written in. Defaults to CApplication::language application language.

The language that the source messages are written in. Defaults to CApplication::language application language.

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