yii\BaseYii::t PHP Method

t() public static method

This is a shortcut method of [[\yii\i18n\I18N::translate()]]. The translation will be conducted according to the message category and the target language will be used. You can add parameters to a translation message that will be substituted with the corresponding value after translation. The format for this is to use curly brackets around the parameter name as you can see in the following example: php $username = 'Alexander'; echo \Yii::t('app', 'Hello, {username}!', ['username' => $username]); Further formatting of message parameters is supported using the PHP intl extensions message formatter. See [[\yii\i18n\I18N::translate()]] for more details.
public static t ( string $category, string $message, array $params = [], string $language = null ) : string
$category string the message category.
$message string the message to be translated.
$params array the parameters that will be used to replace the corresponding placeholders in the message.
$language string the language code (e.g. `en-US`, `en`). If this is null, the current [[\yii\base\Application::language|application language]] will be used.
return string the translated message.
    public static function t($category, $message, $params = [], $language = null)
    {
        if (static::$app !== null) {
            return static::$app->getI18n()->translate($category, $message, $params, $language ?: static::$app->language);
        } else {
            $p = [];
            foreach ((array) $params as $name => $value) {
                $p['{' . $name . '}'] = $value;
            }
            return $p === [] ? $message : strtr($message, $p);
        }
    }