yii\i18n\GettextMessageSource::loadFallbackMessages PHP Метод

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.
    protected function loadFallbackMessages($category, $fallbackLanguage, $messages, $originalMessageFile)
    {
        $fallbackMessageFile = $this->getMessageFilePath($fallbackLanguage);
        $fallbackMessages = $this->loadMessagesFromFile($fallbackMessageFile, $category);
        if ($messages === null && $fallbackMessages === null && $fallbackLanguage !== $this->sourceLanguage && $fallbackLanguage !== substr($this->sourceLanguage, 0, 2)) {
            Yii::error("The message file for category '{$category}' does not exist: {$originalMessageFile} " . "Fallback file does not exist as well: {$fallbackMessageFile}", __METHOD__);
        } elseif (empty($messages)) {
            return $fallbackMessages;
        } elseif (!empty($fallbackMessages)) {
            foreach ($fallbackMessages as $key => $value) {
                if (!empty($value) && empty($messages[$key])) {
                    $messages[$key] = $fallbackMessages[$key];
                }
            }
        }
        return (array) $messages;
    }