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