Cldr.Message (Cldr Messages v0.10.0) View Source
Implements the ICU Message Format with functions to parse and interpolate messages.
Link to this section Summary
Functions
Formats a message into a canonical form.
Formats a message into a canonical form or raises if the message cannot be parsed.
Returns the Jaro distance between two messages.
Returns the Jaro distance between two messages or raises.
Link to this section Types
Link to this section Functions
Formats a message into a canonical form.
This allows for messages to be compared
directly, or using Cldr.Message.jaro_distance/3
.
Arguments
message
is a CLDR message in binary formoptions
is a keyword list of options. The default is[]
Options
:trim
determines if the message is trimmed of whitespace before formatting. The default istrue
.:pretty
determines if the message if formatted with indentation to aid readability. The default isfalse
.
Returns
{ok, canonical_message}
wherecanonical_message
is a binary or{:error, {exception, reason}}
Examples
Formats a message into a canonical form or raises if the message cannot be parsed.
This allows for messages to be compared
directly, or using Cldr.Message.jaro_distance/3
.
Arguments
message
is a CLDR message in binary formoptions
is a keyword list of options. The default is[]
Options
:trim
determines if the message is trimmed of whitespace before formatting. The default istrue
.:pretty
determines if the message if formatted with indentation to aid readability. The default isfalse
.
Returns
canonical_message
wherecanonical_message
is a binary orraises an exception
Examples
Specs
Specs
Returns the Jaro distance between two messages.
This allows for fuzzy matching of message which can be helpful when a message string is changed but the semantics remain the same.
Arguments
message1
is a CLDR message in binary formmessage2
is a CLDR message in binary formoptions
is a keyword list of options. The default is[]
Options
:trim
determines if the message is trimmed of whitespace before formatting. The default isfalse
.
Returns
{ok, distance}
wheredistance
is a float value between 0.0 (equates to no similarity) and 1.0 (is an exact match) representing Jaro distance betweenmessage1
andmessage2
or{:error, {exception, reason}}
Examples
Returns the Jaro distance between two messages or raises.
This allows for fuzzy matching of message which can be helpful when a message string is changed but the semantics remain the same.
Arguments
message1
is a CLDR message in binary formmessage2
is a CLDR message in binary formoptions
is a keyword list of options. The default is[]
Options
:trim
determines if the message is trimmed of whitespace before formatting. The default isfalse
.
Returns
distance
wheredistance
is a float value between 0.0 (equates to no similarity) and 1.0 (is an exact match) representing Jaro distance betweenmessage1
andmessage2
orraises an exception