---
url: /api/renderers/web-components/src/functions/formatMessage.md
---
[pantoken-root](../../../../index.md) / [renderers/web-components/src](../index.md) / formatMessage

# Function: formatMessage()

> **formatMessage**(`locale`, `source`, `params?`): `string`

Alpha

Format an MF2 `source` message for `locale`, substituting `params`. Throws on invalid MF2 syntax
— validate with `@pantoken/i18n-engine`'s `validateMf2` at build time, not at format time.

`messageformat` already isolates each placeholder's formatted value in FSI/PDI bidi marks by
default (its `bidiIsolation: "default"` option) — [isolate](isolate.md) is for interpolation done
OUTSIDE of MF2 formatting, not needed here.

## Parameters

### locale

`string`

### source

`string`

### params?

`Record`<`string`, `unknown`>

## Returns

`string`
