yii\i18n\MessageSource::translate PHP Method

translate() public method

Note that unless [[forceTranslation]] is true, if the target language is the same as the [[sourceLanguage|source language]], the message will NOT be translated. If a translation is not found, a [[EVENT_MISSING_TRANSLATION|missingTranslation]] event will be triggered.
public translate ( string $category, string $message, string $language ) : string | boolean
$category string the message category
$message string the message to be translated
$language string the target language
return string | boolean the translated message or false if translation wasn't found or isn't required
    public function translate($category, $message, $language)
    {
        if ($this->forceTranslation || $language !== $this->sourceLanguage) {
            return $this->translateMessage($category, $message, $language);
        } else {
            return false;
        }
    }