Localize.Message.Print (Localize v1.4.0)

Copy Markdown View Source

Converts a MessageFormat 2 AST back to its canonical string form.

Used by Localize.Message.canonical_message/2.

Summary

Functions

Converts a parsed MF2 AST back to a canonical message string.

Functions

to_string(ast, options \\ [])

@spec to_string(list() | tuple(), Keyword.t()) :: String.t() | {:error, Exception.t()}

Converts a parsed MF2 AST back to a canonical message string.

Arguments

  • ast is a parsed MF2 message AST as returned by Localize.Message.Parser.parse/1.

  • options is a keyword list of options (currently unused but reserved for future use).

Returns

  • A canonical message string.

Examples

iex> {:ok, ast} = Localize.Message.Parser.parse("Hello {$name}!")
iex> Localize.Message.Print.to_string(ast)
"Hello {$name}!"