framework/validators/Validator.php
protected function formatMessage($message, $params)
    {
        if (Yii::$app !== null) {
            return \Yii::$app->getI18n()->format($message, $params, Yii::$app->language);
        }

        $placeholders = [];
        foreach ((array) $params as $name => $value) {
            $placeholders['{' . $name . '}'] = $value;
        }

        return ($placeholders === []) ? $message : strtr($message, $placeholders);
    }
protected function formatMessage($message, $params)
    {
        if (Yii::$app !== null) {
            return \Yii::$app->getI18n()->format($message, $params, Yii::$app->language);
        }

        $placeholders = [];
        foreach ((array) $params as $name => $value) {
            $placeholders['{' . $name . '}'] = $value;
        }

        return ($placeholders === []) ? $message : strtr($message, $placeholders);
    }
protected function formatMessage ( $ message , $ params ) { if ( Yii :: $ app !== null ) { return \ Yii :: $ app -> getI18n ( ) -> format ( $ message , $ params , Yii :: $ app -> language ) ; } $ placeholders = [ ] ; foreach ( ( array ) $ params as $ name => $ value ) { $ placeholders [ '{' . $ name . '}' ] = $ value ; } return ( $ placeholders === [ ] ) ? $ message : strtr ( $ message , $ placeholders ) ; }
Formats a mesage using the I18N, or simple strtr if `\Yii::$app` is not available.
@param string $message
@param array $params
@since 2.0.12
@return string
Formats a mesage using the I18N or simple strtr if \ Yii :: $app is not available .