The ~M sigil, which returns a message in canonical form at compile time.
A message may be laid out with white space for readability, but Gettext
uses the message string as its key, so a change of layout would make a new
message. ~M returns the canonical form of the message
(Localize.Message.MF1.canonical_message/2) instead, and a message that
cannot be parsed is a compile error.
This is the ~M of Cldr.Message.Sigil from ex_cldr_messages, with the
same output. A MessageFormat 2 message is canonicalized by
Localize.Message.canonical_message/2. Localize.Message.Sigils defines
its own ~M for MF2 messages, so import one or the other.
Summary
Functions
Returns an MF1 message in canonical form.
Functions
Returns an MF1 message in canonical form.
The message is pretty printed by default, with each selector clause on a line of its own, which translators find easier to read.
Arguments
messageis the sigil's text, without interpolation or escapes.modifiersare the sigil's modifiers.
Modifiers
ppretty prints the message (the default).ureturns the message on one line.
Returns
- The canonical message, as a string literal.
Examples
iex> import Localize.Message.MF1.Sigils
iex> ~M(An ICU message)
"An ICU message"
iex> ~M"{n, plural, other {# items} one {# item}}"u
"{n, plural, one {# item} other {# items}}"