loadMessages() protected method

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.
See also: loadFallbackMessages
See also: sourceLanguage
protected loadMessages ( string $category, string $language ) : array
$category string the message category
$language string the target language
return array the loaded messages. The keys are original messages, and the values are translated messages.
 /**
  * @inheritdoc
  */
 protected function loadMessages($category, $language)
 {
     if (!isset($this->scopeCache[$category])) {
         if (!is_null($this->scope)) {
             if (strripos($category, $this->scope) === FALSE) {
                 throw new \Exception("Invalid translation category {$category}, not in scope: " . $this->scope);
             }
             $this->scopeCache[$category] = substr($category, strlen($this->scope));
         } else {
             $this->scopeCache[$category] = $category;
         }
     }
     return parent::loadMessages($this->scopeCache[$category], $language);
 }