Cldr.Unit.Format (Cldr Units v3.5.0-rc.0) View Source
Link to this section Summary
Functions
Traverses the components of a unit and resolves a list of base units with their gramatical case and plural selector definitions for a given locale.
Traverses a unit's decomposition and invokes a function on each node of the composition tree.
Link to this section Functions
Specs
grammar(Cldr.Unit.t(), Keyword.t()) :: grammar_list() | {grammar_list(), grammar_list()}
Traverses the components of a unit and resolves a list of base units with their gramatical case and plural selector definitions for a given locale.
This function relies upon the internal
representation of units and grammatical features
and is primarily for the support of
formatting a function through Cldr.Unit.to_string/2
.
Arguments
unit
is at:Cldr.Unit
or a binary unit string
Options
:locale
is any valid locale name returned byCldr.known_locale_names/1
or at:Cldr.LanguageTag
struct. The default isCldr.get_locale/0
backend
is any module that includesuse Cldr
and therefore is aCldr
backend module. The default isCldr.default_backend!/0
.
Returns
Examples
Traverses a unit's decomposition and invokes a function on each node of the composition tree.
Arguments
unit
is any unit returned byCldr.Unit.new/2
fun
is any single-arity function. It will be invoked for each node of the composition tree. The argument is a tuple of the following form:{:unit, argument}
{:times, {argument_1, argument_2}}
{:prefix, {prefix_unit, argument}}
{:power, {power_unit, argument}}
{:per, {argument_1, argument_2}}
Where the arguments are the results returned from thefun/1
.
Returns
The result returned from fun/1