framework/i18n/I18N.php
public function translate($category, $message, $params, $language)
    {
        $messageSource = $this->getMessageSource($category);
        $translation = $messageSource->translate($category, $message, $language);
        if ($translation === false) {
            return $this->format($message, $params, $messageSource->sourceLanguage);
        }

        return $this->format($translation, $params, $language);
    }
public function translate($category, $message, $params, $language)
    {
        $messageSource = $this->getMessageSource($category);
        $translation = $messageSource->translate($category, $message, $language);
        if ($translation === false) {
            return $this->format($message, $params, $messageSource->sourceLanguage);
        }

        return $this->format($translation, $params, $language);
    }
Translates a message to the specified language.

After translation the message will be formatted using [[MessageFormatter]] if it contains
ICU message format and `$params` are not empty.

@param string $category the message category.
@param string $message the message to be translated.
@param array $params the parameters that will be used to replace the corresponding placeholders in the message.
@param string $language the language code (e.g. `en-US`, `en`).
@return string the translated and formatted message.