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;
    }