private function formatMessage($format, $context = []) {
        $format = $this->translate($format);

        $msg = preg_replace_callback('`({[^{}]+})`', function ($m) use ($context) {
            $args = array_filter(array_map('trim', explode(',', trim($m[1], '{}'))));
            $field = array_shift($args);

            switch ($field) {
                case 'value':
                    return $this->formatValue($context[$field] ?? null);
                case 'field':
                    $field = $context['field'] ?: 'value';
                    return $this->formatFieldName($field);
                default:
                    return $this->formatField(isset($context[$field]) ? $context[$field] : null, $args);
            }
        }, $format);
        return $msg;
    }