Cldr v0.1.0 Cldr

Cldr provides functions to localise numbers, currencies, lists and dates/times to an appropriate locale as defined by the CLDR data maintained by the ICU.

The most commonly used functions are:

Summary

Functions

Returns a list of all the locales defined in the CLDR repository

Returns the directory path name where the CLDR json data is kept

Returns the default locale name

Return the current locale to be used for Cldr functions that take an optional locale parameter for which a locale is not supplied

Returns a boolean indicating if the specified locale is configured and available in Cldr

Returns a list of the known locales

Returns a boolean indicating if the specified locale is available in CLDR

Returns a list of all requested locales

Set the current locale to be used for Cldr functions that take an optional locale parameter for which a locale is not supplied

Returns a list of the locales that are configured, but not known in CLDR

Returns the version of the CLDR repository as a tuple

Functions

all_locales()
all_locales() :: [Locale.t]

Returns a list of all the locales defined in the CLDR repository.

Note that not necessarily all of these locales are available since functions are only generated for configured locales which is most cases will be a subset of locales defined in CLDR.

See also: requested_locales/0 and known_locales/0

data_dir()

Returns the directory path name where the CLDR json data is kept.

default_locale()
default_locale() :: [Locale.t]

Returns the default locale name.

Example

iex> Cldr.get_locale()
"en"
get_locale()
get_locale() :: Locale.t

Return the current locale to be used for Cldr functions that take an optional locale parameter for which a locale is not supplied.

known_locale?(locale)
known_locale?(Locale.t) :: boolean

Returns a boolean indicating if the specified locale is configured and available in Cldr.

Examples

iex> Cldr.known_locale?("en")
true

iex> Cldr.known_locale?("!!")
false
known_locales()
known_locales() :: [Locale.t] | []

Returns a list of the known locales.

Known locales are those locales which are the subset of all CLDR locales that have been configured for use either directly in the config.exs file or in Gettext.

locale_exists?(locale)
locale_exists?(Locale.t) :: boolean

Returns a boolean indicating if the specified locale is available in CLDR.

The return value depends on whether the locale is defined in the CLDR repository. It does not necessarily mean the locale is configured for Cldr. See also Cldr.known_locale?/1.

Examples

iex> Cldr.locale_exists? "en-AU"
true

iex> Cldr.locale_exists? "en-SA"
false
requested_locales()
requested_locales() :: [Locale.t] | []

Returns a list of all requested locales.

The list is the combination of configured locales, Gettext locales and the default locale.

See also known_locales/0 and all_locales/0

set_locale(locale)
set_locale(Locale.t) :: Locale.t

Set the current locale to be used for Cldr functions that take an optional locale parameter for which a locale is not supplied.

unknown_locales()
unknown_locales() :: [Locale.t] | []

Returns a list of the locales that are configured, but not known in CLDR.

Since we check at compile time for any unknown locales and raise and exception this function should always return an empty list.

version()

Returns the version of the CLDR repository as a tuple

Example

iex> Cldr.version
{"31", "0", "0"}