public function format($message, $params, $language)
    {
        $params = (array) $params;
        if ($params === []) {
            return $message;
        }

        if (preg_match('~{\s*[\w.]+\s*,~u', $message)) {
            $formatter = $this->getMessageFormatter();
            $result = $formatter->format($message, $params, $language);
            if ($result === false) {
                $errorMessage = $formatter->getErrorMessage();
                Yii::warning("Formatting message for language '$language' failed with error: $errorMessage. The message being formatted was: $message.", __METHOD__);

                return $message;
            }

            return $result;
        }

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

        return strtr($message, $p);
    }
public function format($message, $params, $language)
    {
        $params = (array) $params;
        if ($params === []) {
            return $message;
        }

        if (preg_match('~{\s*[\w.]+\s*,~u', $message)) {
            $formatter = $this->getMessageFormatter();
            $result = $formatter->format($message, $params, $language);
            if ($result === false) {
                $errorMessage = $formatter->getErrorMessage();
                Yii::warning("Formatting message for language '$language' failed with error: $errorMessage. The message being formatted was: $message.", __METHOD__);

                return $message;
            }

            return $result;
        }

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

        return strtr($message, $p);
    }
public function format ( $ message , $ params , $ language ) { $ params = ( array ) $ params ; if ( $ params === [ ] ) { return $ message ; } if ( preg_match ( '~{\s*[\w.]+\s*,~u' , $ message ) ) { $ formatter = $ this -> getMessageFormatter ( ) ; $ result = $ formatter -> format ( $ message , $ params , $ language ) ; if ( $ result === false ) { $ errorMessage = $ formatter -> getErrorMessage ( ) ; Yii :: warning ( "Formatting message for language '$language' failed with error: $errorMessage. The message being formatted was: $message." , __METHOD__ ) ; return $ message ; } return $ result ; } $ p = [ ] ; foreach ( $ params as $ name => $ value ) { $ p [ '{' . $ name . '}' ] = $ value ; } return strtr ( $ message , $ p ) ; }
Formats a message using [[MessageFormatter]].

@param string $message the message to be formatted.
@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 formatted message.
Formats a message using [[ MessageFormatter ]] .