Skip to content

pantoken / renderers/web-components/src / formatMessage

函数: formatMessage()

formatMessage(locale, source, params?): string

Alpha

locale 格式化一个 MF2 source 消息,替换 params。在 MF2 语法无效时抛出异常 — 在构建时使用 @pantoken/i18n-enginevalidateMf2 进行验证,而不是在格式化时验证。

messageformat 默认已经在 FSI/PDI 双向标记中隔离每个占位符的格式化值(其 bidiIsolation: "default" 选项)——isolate 用于在 MF2 格式化 之外 进行的插值,这里不需要。

参数

locale

string

source

string

params?

Record<string, unknown>

返回值

string