PHP Класс yii\mongodb\i18n\MongoDbMessageSource

This message source uses single collection for the message translations storage, defined via [[collection]]. each entry in this collection should have 3 fields: - language: string, translation language - category: string, name translation category - messages: array, list of actual message translations, in each element: the key is raw message name value - message translation. For example: json { "category": "app", "language": "de", "messages": { "Hello world!": "Hallo Welt!", "The dog runs fast.": "Der Hund rennt schnell.", ... }, }
С версии: 2.0.5
Автор: Paul Klimov ([email protected])
Наследование: extends yii\i18n\MessageSource
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$cache the cache object or the application component ID of the cache object. The messages data will be cached using this cache object. Note, that to enable caching you have to set [[enableCaching]] to true, otherwise setting this property has no effect. After the MongoDbMessageSource object is created, if you want to change this property, you should only assign it with a cache object. This can also be a configuration array for creating the object.
$cachingDuration the time in seconds that the messages can remain valid in cache. Use 0 to indicate that the cached data will never expire.
$collection the name of the MongoDB collection, which stores translated messages. This collection is better to be pre-created with fields 'category' and 'language' indexed.
$db the MongoDB connection object or the application component ID of the MongoDB connection. After the MongoDbMessageSource object is created, if you want to change this property, you should only assign it with a MongoDB connection object. This can also be a configuration array for creating the object.
$enableCaching whether to enable caching translated messages

Открытые методы

Метод Описание
init ( ) Initializes the DbMessageSource component.

Защищенные методы

Метод Описание
loadMessages ( string $category, string $language ) : array Loads the message translation for the specified language and category.
loadMessagesFromDb ( string $category, string $language ) : array Loads the messages from MongoDB.

Описание методов

init() публичный Метод

This method will initialize the [[db]] property to make sure it refers to a valid DB connection. Configured [[cache]] component would also be initialized.
public init ( )

loadMessages() защищенный Метод

If translation for specific locale code such as en-US isn't found it tries more generic en.
protected loadMessages ( string $category, string $language ) : array
$category string the message category
$language string the target language
Результат array the loaded messages. The keys are original messages, and the values are translated messages.

loadMessagesFromDb() защищенный Метод

You may override this method to customize the message storage in the MongoDB.
protected loadMessagesFromDb ( string $category, string $language ) : array
$category string the message category.
$language string the target language.
Результат array the messages loaded from database.

Описание свойств

$cache публичное свойство

the cache object or the application component ID of the cache object. The messages data will be cached using this cache object. Note, that to enable caching you have to set [[enableCaching]] to true, otherwise setting this property has no effect. After the MongoDbMessageSource object is created, if you want to change this property, you should only assign it with a cache object. This can also be a configuration array for creating the object.
См. также: cachingDuration
См. также: enableCaching
public $cache

$cachingDuration публичное свойство

the time in seconds that the messages can remain valid in cache. Use 0 to indicate that the cached data will never expire.
См. также: enableCaching
public $cachingDuration

$collection публичное свойство

the name of the MongoDB collection, which stores translated messages. This collection is better to be pre-created with fields 'category' and 'language' indexed.
public $collection

$db публичное свойство

the MongoDB connection object or the application component ID of the MongoDB connection. After the MongoDbMessageSource object is created, if you want to change this property, you should only assign it with a MongoDB connection object. This can also be a configuration array for creating the object.
public $db

$enableCaching публичное свойство

whether to enable caching translated messages
public $enableCaching