CPhpMessageSource

Namemessages
ClassCPhpMessageSource
Location/home/vhosts/app-manager.eu5.org/framework/i18n/CPhpMessageSource.php
CPhpMessageSource represents a message source that stores translated messages in PHP scripts.

CPhpMessageSource uses PHP files and arrays to keep message translations.
  • All translations are saved under the {@link basePath} directory.
  • Translations in one language are kept as PHP files under an individual subdirectory whose name is the same as the language ID. Each PHP file contains messages belonging to the same category, and the file name is the same as the category name.
  • Within a PHP file, an array of (source, translation) pairs is returned. For example:
    return array(
        'original message 1' => 'translated message 1',
        'original message 2' => 'translated message 2',
    );
    
When {@link cachingDuration} is set as a positive number, message translations will be cached. Messages for an extension class (e.g. a widget, a module) can be specially managed and used. In particular, if a message belongs to an extension whose class name is Xyz, then the message category can be specified in the format of 'Xyz.categoryName'. And the corresponding message file is assumed to be 'BasePath/messages/LanguageID/categoryName.php', where 'BasePath' refers to the directory that contains the extension class file. When using Yii::t() to translate an extension message, the category name should be set as 'Xyz.categoryName'.

Options

Displaying 1-6 of 6 results.
NameValueDescriptionType
cachingDuration0The time in seconds that the messages can remain valid in cache. Defaults to 0, meaning the caching is disabled.integer
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.string
basePathnullThe base path for all translated messages. Defaults to null, meaning the "messages" subdirectory of the application directory (e.g. "protected/messages").string
forceTranslationfalseWhether 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.4boolean
behaviorsarray()The behaviors that should be attached to this component. The behaviors will be attached to the component when {@link init} is called. Please refer to {@link CModel::behaviors} on how to specify the value of this property.array
languagenullThe language that the source messages are written in.string
Free Web Hosting