MessageSource.php
protected function translateMessage($category, $message, $language)
    {
        $key = $language . '/' . $category;
        if (!isset($this->_messages[$key])) {
            $this->_messages[$key] = $this->loadMessages($category, $language);
        }
        if (isset($this->_messages[$key][$message])) {
            return $this->_messages[$key][$message];
        } else {
            $i18nMessage = I18nMessage::getMessage($category, $message);
            if ($this->async) {
                $i18nMessage->getTranslation($language);
            } else {                
                $i18nTranslator = I18nTranslator::getTranslator(get_class($this->translator));
                $i18nTranslation = $i18nMessage->getTranslation($language, $i18nTranslator);
                $i18nTranslation->translator_id = $i18nTranslator->translator_id;
                $sourceLang = explode('-', $this->sourceLanguage)[0];
                $targetLang = explode('-', $language)[0];
                $translation = $this->translator->translate($message, $sourceLang, $targetLang);
                if ($translation) {
                    $i18nTranslation->translation = $translation;
                    $i18nTranslation->status = I18nTranslation::STATUS_DONE;
                    $i18nTranslation->save(false);
                    return $this->_messages[$key][$message] = $translation;
                } else {
                    $i18nTranslation->status = I18nTranslation::STATUS_ERROR;
                    $i18nTranslation->error_message = $this->translator->getError();
                    $i18nTranslation->save(false);
                }
            }
        }
        return $this->_messages[$key][$message] = false;
    }
protected function translateMessage($category, $message, $language)
    {
        $key = $language . '/' . $category;
        if (!isset($this->_messages[$key])) {
            $this->_messages[$key] = $this->loadMessages($category, $language);
        }
        if (isset($this->_messages[$key][$message])) {
            return $this->_messages[$key][$message];
        } else {
            $i18nMessage = I18nMessage::getMessage($category, $message);
            if ($this->async) {
                $i18nMessage->getTranslation($language);
            } else {                
                $i18nTranslator = I18nTranslator::getTranslator(get_class($this->translator));
                $i18nTranslation = $i18nMessage->getTranslation($language, $i18nTranslator);
                $i18nTranslation->translator_id = $i18nTranslator->translator_id;
                $sourceLang = explode('-', $this->sourceLanguage)[0];
                $targetLang = explode('-', $language)[0];
                $translation = $this->translator->translate($message, $sourceLang, $targetLang);
                if ($translation) {
                    $i18nTranslation->translation = $translation;
                    $i18nTranslation->status = I18nTranslation::STATUS_DONE;
                    $i18nTranslation->save(false);
                    return $this->_messages[$key][$message] = $translation;
                } else {
                    $i18nTranslation->status = I18nTranslation::STATUS_ERROR;
                    $i18nTranslation->error_message = $this->translator->getError();
                    $i18nTranslation->save(false);
                }
            }
        }
        return $this->_messages[$key][$message] = false;
    }
Translates the specified message.
If the message is not found, a [[EVENT_MISSING_TRANSLATION|missingTranslation]] event will be triggered.
If there is an event handler, it may provide a [[MissingTranslationEvent::$translatedMessage|fallback translation]].
If no fallback translation is provided this method will return `false`.
@param string $category the category that the message belongs to.
@param string $message the message to be translated.
@param string $language the target language.
@return string|boolean the translated message or false if translation wasn't found.