if (class_exists('MessageFormatter', false) && preg_match('~{\s*[\d\w]+\s*,~u', $message)) {
$formatter = new MessageFormatter($language, $message);
if ($formatter === null) {
\Yii::$app->getLog()->log("$language message from category $category is invalid. Message is: $message.", Logger::LEVEL_WARNING, 'application');
Yii::warning("$language message from category $category is invalid. Message is: $message.");
return $message;
}
$result = $formatter->format($params);
if ($result === false) {
$errorMessage = $formatter->getErrorMessage();
Yii::warning("$language message from category $category failed with error: $errorMessage. Message is: $message.");
return $message;
} else {
$result = $formatter->format($params);
if ($result === false) {
$errorMessage = $formatter->getErrorMessage();
\Yii::$app->getLog()->log("$language message from category $category failed with error: $errorMessage. Message is: $message.", Logger::LEVEL_WARNING, 'application');