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
unitis at:Cldr.Unitor a binary unit string
Options
:localeis any valid locale name returned byCldr.known_locale_names/1or at:Cldr.LanguageTagstruct. The default isCldr.get_locale/0backendis any module that includesuse Cldrand therefore is aCldrbackend 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
unitis any unit returned byCldr.Unit.new/2funis 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