PHP Класс yii\i18n\GettextMessageSource

Each GettextMessageSource instance represents the message translations for a single domain. And each message category represents a message context in Gettext. Translated messages are stored as either a MO or PO file, depending on the [[useMoFile]] property value. All translations are saved under the [[basePath]] directory. Translations in one language are kept as MO or PO files under an individual subdirectory whose name is the language ID. The file name is specified via [[catalog]] property, which defaults to 'messages'.
С версии: 2.0
Автор: Qiang Xue ([email protected])
Наследование: extends MessageSource
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$basePath string
$catalog string
$useBigEndian boolean
$useMoFile boolean

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

Метод Описание
getMessageFilePath ( string $language ) : string Returns message file path for the specified language and category.
loadFallbackMessages ( string $category, string $fallbackLanguage, array $messages, string $originalMessageFile ) : array The method is normally called by [[loadMessages]] to load the fallback messages for the language.
loadMessages ( string $category, string $language ) : array Loads the message translation for the specified $language and $category.
loadMessagesFromFile ( string $messageFile, string $category ) : array | null Loads the message translation for the specified language and category or returns null if file doesn't exist.

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

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

Returns message file path for the specified language and category.
protected getMessageFilePath ( string $language ) : string
$language string the target language
Результат string path to message file

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

Method tries to load the $category messages for the $fallbackLanguage and adds them to the $messages array.
С версии: 2.0.7
protected loadFallbackMessages ( string $category, string $fallbackLanguage, array $messages, string $originalMessageFile ) : array
$category string the message category
$fallbackLanguage string the target fallback language
$messages array the array of previously loaded translation messages. The keys are original messages, and the values are the translated messages.
$originalMessageFile string the path to the file with messages. Used to log an error message in case when no translations were found.
Результат array the loaded messages. The keys are original messages, and the values are the translated messages.

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

If translation for specific locale code such as en-US isn't found it tries more generic en. When both are present, the en-US messages will be merged over en. See [[loadFallbackMessages]] for details. If the $language is less specific than [[sourceLanguage]], the method will try to load the messages for [[sourceLanguage]]. For example: [[sourceLanguage]] is en-GB, $language is en. The method will load the messages for en and merge them over en-GB.
См. также: loadFallbackMessages
См. также: sourceLanguage
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.

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

Loads the message translation for the specified language and category or returns null if file doesn't exist.
protected loadMessagesFromFile ( string $messageFile, string $category ) : array | null
$messageFile string path to message file
$category string the message category
Результат array | null array of messages or null if file not found

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

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

public string $basePath
Результат string

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

public string $catalog
Результат string

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

public bool $useBigEndian
Результат boolean

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

public bool $useMoFile
Результат boolean