src/I18n/GettextMessageSource.php
protected function loadFallbackMessages($category, $fallbackLanguage, $messages, $originalMessageFile)
    {
        $fallbackMessageFile = $this->getMessageFilePath($fallbackLanguage);
        return $this->loadMessagesFromFile($fallbackMessageFile, $category)
            ->otherwise(function() { return null; })
            ->then(function($fallbackMessages) use ($category, $fallbackLanguage, $messages, $originalMessageFile, $fallbackMessageFile) {
                if (
                    $messages === null && $fallbackMessages === null
                    && $fallbackLanguage !== $this->sourceLanguage
                    && $fallbackLanguage !== substr($this->sourceLanguage, 0, 2)
                ) {
                    Reaction::warning("The message file for category '$category' does not exist: $originalMessageFile "
                        . "Fallback file does not exist as well: $fallbackMessageFile");
                } 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;
            });
    }
protected function loadFallbackMessages($category, $fallbackLanguage, $messages, $originalMessageFile)
    {
        $fallbackMessageFile = $this->getMessageFilePath($fallbackLanguage);
        return $this->loadMessagesFromFile($fallbackMessageFile, $category)
            ->otherwise(function() { return null; })
            ->then(function($fallbackMessages) use ($category, $fallbackLanguage, $messages, $originalMessageFile, $fallbackMessageFile) {
                if (
                    $messages === null && $fallbackMessages === null
                    && $fallbackLanguage !== $this->sourceLanguage
                    && $fallbackLanguage !== substr($this->sourceLanguage, 0, 2)
                ) {
                    Reaction::warning("The message file for category '$category' does not exist: $originalMessageFile "
                        . "Fallback file does not exist as well: $fallbackMessageFile");
                } 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;
            });
    }
The method is normally called by [[loadMessages]] to load the fallback messages for the language.
Method tries to load the $category messages for the $fallbackLanguage and adds them to the $messages array.

@param string $category the message category
@param string $fallbackLanguage the target fallback language
@param array $messages the array of previously loaded translation messages.
The keys are original messages, and the values are the translated messages.
@param string $originalMessageFile the path to the file with messages. Used to log an error message
in case when no translations were found.
@return ExtendedPromiseInterface with array the loaded messages. The keys are original messages, and the values are the translated messages.