Implements sigil ~M to canonicalize an ICU MessageFormat 2 message.
ICU messages allow for whitespace to be used to format the message
for developer and translator readability. At the same time, gettext
uses the message string as a key when resolving translations.
Therefore a developer or translator that modifies the message for readability may unintentionally create a new message rather than replace the old one simply because the message strings don't match exactly.
The sigil ~M therefore introduces a way for the developer to ensure
the message is in a canonical format during compilation and therefore
both error check the message format and ensure the message is in a
canonical form irrespective of developer formatting.
Compile-time validation
~M parses the message at compile time. A syntax error fails
compilation and the raised CompileError points at the exact line
and column of the error inside the sigil body, adjusted to the
sigil's source location so editors can jump directly to the
offending character (including inside multi-line heredoc sigils).
Summary
Functions
Handles the sigil ~M for ICU MessageFormat 2 message strings.
Functions
Handles the sigil ~M for ICU MessageFormat 2 message strings.
It returns a canonically formatted string without interpolations and without escape characters, except for the escaping of the closing sigil character itself.
A canonically formatted string is pretty-printed by default returning a potentially multi-line string. This is intended to produce a result which is easier to comprehend for translators.
Modifiers
p(default) — pretty-print the message with indentation.u— return a non-pretty-printed (compact) string.
Examples
iex> import Localize.Message.Sigil
iex> ~M(An ICU message)
"An ICU message"