Cldr v0.0.12 Cldr.Rbnf

Functions to implement Rules Based Number Formatting (rbnf)

During compilation we want to look up the configured locales and generate the functions needed for only those locales.

For any other recognized locale we need a way to either fallback to a known locale, or error exit (configurable)

Note that many of the functions in this module rely on having the raw XML RBNF files from the CLDR repository. The repository can be installed by running:

mix cldr.download

Unless you are interested in the muysteries of how the repository is put together this is not recommended.

Summary

Functions

Returns a map that merges all rules by the primary dimension of RuleGroup, within which rbnf rules are keyed by locale

Returns the rbnf rules for a locale or {:error, :rbnf_file_not_found}

Returns the list of locales that that have RBNF defined

Functions

for_all_locales()
for_all_locales() :: %{}

Returns a map that merges all rules by the primary dimension of RuleGroup, within which rbnf rules are keyed by locale.

This function is primarily intended to support compile-time generation of functions to process rbnf rules.

for_locale(locale)
for_locale(Locale.t) :: %{} | nil

Returns the rbnf rules for a locale or {:error, :rbnf_file_not_found}

  • locale is any locale returned by Rbnf.known_locales/0.

Note that for_locale/1 does not raise if the locale does not exist like the majority of Cldr. This is by design since the set of locales that have rbnf rules is substantially less than the set of locales supported by Cldr.

known_locales()

Returns the list of locales that that have RBNF defined

This list is the set of known locales for which there are rbnf rules defined.