Function: parseMessage()
parseMessage(
message,source?):MessagePart[]
Parse an ICU MessageFormat message into its parts, to inspect it (its arguments: messageArguments). The syntax: {name}; {name, number} with the styles integer, percent, currency, currency/XXX; {name, date} and {name, time} with the styles short, medium, long, full; {name, plural, ...} (with offset:n), {name, selectordinal, ...} and {name, select, ...}, each requiring an other option; # in a plural; '' for an apostrophe and '{...}' to quote the braces (and # in a plural). Other argument types and the skeletons (::currency/EUR) are not supported.
Parameters
message
string
The message.
source?
string
Where the message comes from (zh-CN: order.count), the prefix of the error messages: 'message' by default.
Returns
The parts of the message.
Throws
When the message is not valid, with the source and the position.
Example
import {parseMessage, type MessagePart} from 'lakutata/com/i18n'
const parts: MessagePart[] = parseMessage('{count, plural, one {# order} other {# orders}} for {customer}')
console.log(parts.length) //3