View Source Cldr.Config (Cldr v2.40.2)

Provider configuration support functions for ex_cldr.

The functions in this module should be considered private use and they may change at any time.

Summary

Functions

Returns the map of aliases for languages, scripts and regions

Returns the map of language tags for all available locales

Returns a boolean indicating whether the language_tags.ebin file exists

Returns a list of all locales in the CLDR repository.

Return the configured application name for cldr

Return the map of calendar preferences by territory

Returns the data that defines start and end of calendar eras.

Returns the calendars available for a given locale name

Returns the path of the CLDR data directory for the ex_cldr app.

Return the root path of the cldr application

Return the path name of the CLDR data directory for a client application.

Returns the directory where downloaded ex_cldr locales files are located.

Returns a list of all locales configured in a Cldr.Config.t struct.

Returns the currency metadata for a locale.

Returns the data that defines time periods of a day for a language.

Return the system-wide default backend

Return the system-wide default locale.

Return the default locale name for a given backend configuration.

Returns the directory where the downloaded CLDR repository files are stored.

Expands wildcards in locale names.

Returns the immediate fallback locale for a locale name. Follows the CLDR TR35 resource bundle lookup algorithm.

Returns the fallback chain for a locale name. Follows the CLDR TR35 resource bundle lookup algorithm.

Get the configured number formats that should be precompiled at application compilation time.

Return the configured Gettext module name or nil.

Returns true if a Gettext module is configured in Cldr and the Gettext module is available.

Return the default gettext locale for a CLDR config.

Returns the CLDR grammatical features data which is used with formatting units.

Returns the CLDR grammatical gender data which is used with formatting units.

Return the configured json lib

Returns a list of strings representing the calendars known to Cldr.

Returns a list of the currencies known in Cldr in upcased atom format.

Return a list of the locales defined in Gettext.

Returns either the locale name (if its known) or false if the locale name is not known.

Returns a list of all locales that are configured and available in the CLDR repository.

Returns the number system types that are known.

Returns a list of strings representing the number systems known to Cldr.

Returns locale and number systems that have the same digits and separators as the supplied one.

Returns either the locale name (if its known and has an rbnf configuration) or false.

Returns a list of all locales that have RBNF data and that are configured and available in the CLDR repository.

Returns a list of atoms representing the territories known to Cldr.

Return the language data that maps valid territories and scripts

Return the saved language tag for the given locale name.

Return the mapping from a territory to a language tag.

Returns the likely subtags map which maps a locale string to %LaguageTag{} representing the likely subtags for that locale string

Returns the filename that contains the json representation of a locale.

Transforms a locale name from the Posix format to the Cldr format

Transforms a locale name from the CLDR format to the Posix format

Returns the location of the json data for a locale

Returns the location of the json data for a locale

Add the fallback locales to a list of configured locales

Return a list of measurement systems

Get the number symbol definitions for a locale

Get the number symbol definitions for a locale or raises if an error

Returns the number system for a given locale and number system name.

Returns the number system names for a locale

Returns the number system types for a locale

Returns the number systems for a locale

Returns the number systems for a locale or raises if there is an error

Returns a map of locale names to its parent locale name.

Return a map of plural ranges

Returns a list of all configured locales.

Identifies the top level keys in the consolidated locale file.

Return the directory where Cldr stores its source core data,

Returns a number system name for a given locale and number system reference.

Returns a map of territory info for all territories known to CLDR.

Get territory info for a specific territory.

Returns a map of territory containers

Returns a map of territory containment

Returns the currency mapping data for territories.

Return a mapping between a subdivision and its containing parents

Return the territory subdivisions

Returns a mapping from Unicode script names to the respective subtag used in BCP 47 language tags.

Returns unit conversion data,

Returns a list of all locales that are configured but not available in the CLDR repository.

Return a map of validity data for a given type.

Returns the version string of the CLDR data repository

Returns the data that defines start and end of calendar weeks, weekends and years

Types

number_system()

@type number_system() :: atom() | String.t()

t()

@type t() :: %Cldr.Config{
  add_fallback_locales: boolean(),
  backend: module(),
  data_dir: String.t(),
  default_currency_format: :currency | :accounting | nil,
  default_locale: String.t(),
  force_locale_download: boolean(),
  generate_docs: boolean(),
  gettext: module() | nil,
  https_proxy: String.t() | nil,
  locales: [binary(), ...] | :all,
  message_formats: map(),
  otp_app: atom() | nil,
  precompile_date_time_formats: [String.t(), ...],
  precompile_interval_formats: [String.t(), ...],
  precompile_number_formats: [String.t(), ...],
  precompile_transliterations: [{atom(), atom()}, ...],
  providers: [atom(), ...],
  suppress_warnings: boolean()
}

Functions

aliases()

Returns the map of aliases for languages, scripts and regions

all_language_tags()

Returns the map of language tags for all available locales

all_language_tags?()

Returns a boolean indicating whether the language_tags.ebin file exists

all_locale_names()

@spec all_locale_names() :: [Cldr.Locale.locale_name(), ...]

Returns a list of all locales in the CLDR repository.

Returns a list of the complete locales list in CLDR, irrespective of whether they are configured for use in the application.

Any configured locales that are not present in this list will raise an exception at compile time.

app_name()

Return the configured application name for cldr

Note this is probably :ex_cldr which is what this app is called on hex.pm

calendar_data()

This function is deprecated. Use Cldr.Config.calendars/0.

See Cldr.Config.calendars/0.

calendar_preferences()

Return the map of calendar preferences by territory

calendars()

Returns the data that defines start and end of calendar eras.

Example

iex> Cldr.Config.calendars() |> Map.get(:gregorian)
%{
  calendar_system: :solar,
  eras: [
    [0, %{end: [0, 12, 31], aliases: ["bc", "bce"], code: :gregory_inverse}],
    [1, %{start: [1, 1, 1], aliases: ["ad", "ce"], code: :gregory}]
  ]
}

calendars_for_locale(locale_name, config)

Returns the calendars available for a given locale name

Example

iex> Cldr.Config.calendars_for_locale "en", TestBackend.Cldr
[:buddhist, :chinese, :coptic, :dangi, :ethiopic, :ethiopic_amete_alem,
 :generic, :gregorian, :hebrew, :indian, :islamic, :islamic_civil,
 :islamic_rgsa, :islamic_tbla, :islamic_umalqura, :japanese, :persian, :roc]

canonical_name(locale_name)

cldr_data_dir()

Returns the path of the CLDR data directory for the ex_cldr app.

This is the directory where base CLDR data files are stored including included locale files.

cldr_home()

Return the root path of the cldr application

client_data_dir(config)

@spec client_data_dir(map()) :: String.t()

Return the path name of the CLDR data directory for a client application.

The order of priority to determine where the client data directory is located is:

  • A specified :data_dir of a backend configuration
  • The specified :data_dir of the backend's :otp_app configuration
  • The specified :data_dir of the global configuration
  • The priv_dir() of a specified :otp_app
  • The priv_dir() of ex_cldr

Note that config_from_opts/1 merges the global config, the otp_app config and the module config together so that :data_dir already resolves this priority in most cases.

The remaining cases are for when no :data_dir is specified.

client_locales_dir(config)

Returns the directory where downloaded ex_cldr locales files are located.

configured_locale_names(config)

@spec configured_locale_names(t()) :: [Cldr.Locale.locale_name()]

Returns a list of all locales configured in a Cldr.Config.t struct.

In order of priority return either:

  • The list of locales configured configured in mix.exs if any

  • The default locale

If the configured locales is :all then all locales in CLDR are configured.

The locale "und" is always added to the list of configured locales since it is required to support some RBNF functions.

The use of :all is not recommended since all 571 locales take quite some time (minutes) to compile. It is however helpful for testing Cldr.

currencies_for(locale_name, config)

Returns the currency metadata for a locale.

Arguments

currencies_for!(locale_name, config)

day_period_info()

Returns the data that defines time periods of a day for a language.

Time period rules are used to define the meaning of "morning", "evening", "noon", "midnight" and potentially other periods on a per-language basis.

Example

iex> Cldr.Config.day_period_info() |> Map.get("fr")
%{"afternoon1" => %{"before" => [18, 0], "from" => [12, 0]},
  "evening1" => %{"before" => [24, 0], "from" => [18, 0]},
  "midnight" => %{"at" => [0, 0]},
  "morning1" => %{"before" => [12, 0], "from" => [4, 0]},
  "night1" => %{"before" => [4, 0], "from" => [0, 0]},
  "noon" => %{"at" => [12, 0]}}

default_backend()

Return the system-wide default backend

default_locale()

Return the system-wide default locale.

default_locale_name(config)

@spec default_locale_name(t() | map()) :: Cldr.Locale.locale_name()

Return the default locale name for a given backend configuration.

In order of priority return either:

  • The default locale for a given backend configuration
  • The global default locale specified in mix.exs under the ex_cldr key
  • The Gettext.get_locale/1 for the current configuration
  • The system-wide default locale which is currently :"en-001"

download_data_dir()

Returns the directory where the downloaded CLDR repository files are stored.

These are the real CLDR data files that are used only for the development of ex_cldr. They are not included in the hex package.

expand_locale_names(locale_names)

@spec expand_locale_names([Cldr.Locale.locale_name() | String.t(), ...]) :: [
  Cldr.Locale.locale_name(),
  ...
]

Expands wildcards in locale names.

Locales often have region variants (for example en-AU is one of 104 variants in CLDR). To make it easier to configure a language and all its variants, a locale can be specified as a regex which will then do a match against all CLDR locales.

For locale names that have a Script or Variant component the base language is also configured since plural rules will fall back to the language for these locale names.

Examples

iex> Cldr.Config.expand_locale_names(["en-A+"])
[:en, :"en-AE", :"en-AG", :"en-AI", :"en-AS", :"en-AT", :"en-AU"]

iex> Cldr.Config.expand_locale_names(["fr-*"])
[
  :fr, :"fr-BE", :"fr-BF", :"fr-BI", :"fr-BJ", :"fr-BL", :"fr-CA",
  :"fr-CD", :"fr-CF", :"fr-CG", :"fr-CH", :"fr-CI", :"fr-CM", :"fr-DJ",
  :"fr-DZ", :"fr-GA", :"fr-GF", :"fr-GN", :"fr-GP", :"fr-GQ", :"fr-HT",
  :"fr-KM", :"fr-LU", :"fr-MA", :"fr-MC", :"fr-MF", :"fr-MG", :"fr-ML",
  :"fr-MQ", :"fr-MR", :"fr-MU", :"fr-NC", :"fr-NE", :"fr-PF", :"fr-PM",
  :"fr-RE", :"fr-RW", :"fr-SC", :"fr-SN", :"fr-SY", :"fr-TD", :"fr-TG",
  :"fr-TN", :"fr-VU", :"fr-WF", :"fr-YT"
]

fallback(locale_name)

Returns the immediate fallback locale for a locale name. Follows the CLDR TR35 resource bundle lookup algorithm.

This function is only intended to return the fallback for the locales defined by CLDR. It does not perform any alias lookup or likely subtag processing.

Algorithm Summary

  1. Decompose the locale name into language, script, territory and variant. CLDR locale names have no more than these four parts but usually have less.

  2. Look for a locale in the following order:

    • language-script-territory
    • language-script
    • language-territory
    • language
  3. At each stage in (2) resolve an alias in parent_locales/1

fallback_chain(locale_name)

Returns the fallback chain for a locale name. Follows the CLDR TR35 resource bundle lookup algorithm.

This function is only intended to return fallback chains for the locales defined by CLDR. It does not perform any alias lookup or likely subtag processing.

The primary purpose for this function is to support including fallback locales in a backend configuration since both RBNF and Subdivision data follows the fallback chain.

Algorithm Summary

  1. Decompose the locale name into language, script, territory and variant. CLDR locale names have no more than these four parts but usually have less.

  2. Look for a locale in the following order:

    • language-script-territory
    • language-script
    • language-territory
    • language
  3. At each stage in (2) resolve an alias in parent_locales/1

get_precompile_number_formats(config)

Get the configured number formats that should be precompiled at application compilation time.

gettext(config)

@spec gettext(t() | map()) :: module() | nil

Return the configured Gettext module name or nil.

gettext_configured?(config)

@spec gettext_configured?(t()) :: boolean() | nil

Returns true if a Gettext module is configured in Cldr and the Gettext module is available.

Example

iex> test_config = TestBackend.Cldr.__cldr__(:config)
iex> Cldr.Config.gettext_configured?(test_config)
true

gettext_default_locale(config)

Return the default gettext locale for a CLDR config.

grammatical_features()

Returns the CLDR grammatical features data which is used with formatting units.

grammatical_gender()

Returns the CLDR grammatical gender data which is used with formatting units.

include_module_docs?(arg1)

json_library()

Return the configured json lib

known_calendars()

Returns a list of strings representing the calendars known to Cldr.

Example

iex> Cldr.Config.known_calendars()
[:buddhist, :chinese, :coptic, :dangi, :ethiopic, :ethiopic_amete_alem,
 :gregorian, :hebrew, :indian, :islamic, :islamic_civil, :islamic_rgsa,
 :islamic_tbla, :islamic_umalqura, :japanese, :persian, :roc]

known_currencies()

Returns a list of the currencies known in Cldr in upcased atom format.

Example

iex> Cldr.Config.known_currencies()
[:ADP, :AED, :AFA, :AFN, :ALK, :ALL, :AMD, :ANG, :AOA, :AOK, :AON, :AOR, :ARA,
 :ARL, :ARM, :ARP, :ARS, :ATS, :AUD, :AWG, :AZM, :AZN, :BAD, :BAM, :BAN, :BBD,
 :BDT, :BEC, :BEF, :BEL, :BGL, :BGM, :BGN, :BGO, :BHD, :BIF, :BMD, :BND, :BOB,
 :BOL, :BOP, :BOV, :BRB, :BRC, :BRE, :BRL, :BRN, :BRR, :BRZ, :BSD, :BTN, :BUK,
 :BWP, :BYB, :BYN, :BYR, :BZD, :CAD, :CDF, :CHE, :CHF, :CHW, :CLE, :CLF, :CLP,
 :CNH, :CNX, :CNY, :COP, :COU, :CRC, :CSD, :CSK, :CUC, :CUP, :CVE, :CYP, :CZK,
 :DDM, :DEM, :DJF, :DKK, :DOP, :DZD, :ECS, :ECV, :EEK, :EGP, :ERN, :ESA, :ESB,
 :ESP, :ETB, :EUR, :FIM, :FJD, :FKP, :FRF, :GBP, :GEK, :GEL, :GHC, :GHS, :GIP,
 :GMD, :GNF, :GNS, :GQE, :GRD, :GTQ, :GWE, :GWP, :GYD, :HKD, :HNL, :HRD, :HRK,
 :HTG, :HUF, :IDR, :IEP, :ILP, :ILR, :ILS, :INR, :IQD, :IRR, :ISJ, :ISK, :ITL,
 :JMD, :JOD, :JPY, :KES, :KGS, :KHR, :KMF, :KPW, :KRH, :KRO, :KRW, :KWD, :KYD,
 :KZT, :LAK, :LBP, :LKR, :LRD, :LSL, :LTL, :LTT, :LUC, :LUF, :LUL, :LVL, :LVR,
 :LYD, :MAD, :MAF, :MCF, :MDC, :MDL, :MGA, :MGF, :MKD, :MKN, :MLF, :MMK, :MNT,
 :MOP, :MRO, :MRU, :MTL, :MTP, :MUR, :MVP, :MVR, :MWK, :MXN, :MXP, :MXV, :MYR,
 :MZE, :MZM, :MZN, :NAD, :NGN, :NIC, :NIO, :NLG, :NOK, :NPR, :NZD, :OMR, :PAB,
 :PEI, :PEN, :PES, :PGK, :PHP, :PKR, :PLN, :PLZ, :PTE, :PYG, :QAR, :RHD, :ROL,
 :RON, :RSD, :RUB, :RUR, :RWF, :SAR, :SBD, :SCR, :SDD, :SDG, :SDP, :SEK, :SGD,
 :SHP, :SIT, :SKK, :SLE, :SLL, :SOS, :SRD, :SRG, :SSP, :STD, :STN, :SUR, :SVC,
 :SYP, :SZL, :THB, :TJR, :TJS, :TMM, :TMT, :TND, :TOP, :TPE, :TRL, :TRY, :TTD,
 :TWD, :TZS, :UAH, :UAK, :UGS, :UGX, :USD, :USN, :USS, :UYI, :UYP, :UYU, :UYW,
 :UZS, :VEB, :VED, :VEF, :VES, :VND, :VNN, :VUV, :WST, :XAF, :XAG, :XAU, :XBA,
 :XBB, :XBC, :XBD, :XCD, :XCG, :XDR, :XEU, :XFO, :XFU, :XOF, :XPD, :XPF, :XPT,
 :XRE, :XSU, :XTS, :XUA, :XXX, :YDD, :YER, :YUD, :YUM, :YUN, :YUR, :ZAL, :ZAR,
 :ZMK, :ZMW, :ZRN, :ZRZ, :ZWD, :ZWL, :ZWR]

known_gettext_locale_names(config)

@spec known_gettext_locale_names(t()) :: [Cldr.Locale.locale_name()]

Return a list of the locales defined in Gettext.

Return a list of locales configured in Gettext or [] if Gettext is not configured.

known_locale_name(locale_name, config)

Returns either the locale name (if its known) or false if the locale name is not known.

known_locale_names(config)

This function is deprecated. Use Cldr.Locale.Loader.known_locale_names/1.
@spec known_locale_names(t() | Cldr.backend()) :: [Cldr.Locale.locale_name()]

Returns a list of all locales that are configured and available in the CLDR repository.

known_number_system_types(config)

Returns the number system types that are known.

known_number_systems()

Returns a list of strings representing the number systems known to Cldr.

Example

iex> Cldr.Config.known_number_systems()
[:adlm, :ahom, :arab, :arabext, :armn, :armnlow, :bali, :beng, :bhks, :brah,
 :cakm, :cham, :cyrl, :deva, :diak, :ethi, :fullwide, :geor, :gong, :gonm, :grek,
 :greklow, :gujr, :guru, :hanidays, :hanidec, :hans, :hansfin, :hant, :hantfin,
 :hebr, :hmng, :hmnp, :java, :jpan, :jpanfin, :jpanyear, :kali, :kawi, :khmr, :knda, :lana, :lanatham,
 :laoo, :latn, :lepc, :limb, :mathbold, :mathdbl, :mathmono, :mathsanb,
 :mathsans, :mlym, :modi, :mong, :mroo, :mtei, :mymr, :mymrshan, :mymrtlng, :nagm,
 :newa, :nkoo, :olck, :orya, :osma, :rohg, :roman, :romanlow, :saur, :segment, :shrd,
 :sind, :sinh, :sora, :sund, :takr, :talu, :taml, :tamldec, :telu, :thai, :tibt,
 :tirh, :tnsa, :vaii, :wara, :wcho]

known_number_systems_like(locale_name, number_system, config)

@spec known_number_systems_like(Cldr.Locale.locale_name(), number_system(), t()) ::
  {:ok, list()} | {:error, {module(), String.t()}}

Returns locale and number systems that have the same digits and separators as the supplied one.

Transliterating between locale & number systems is expensive. To avoid unnecessary transliteration we look for locale and number systems that have the same digits and separators. Typically we are comparing to locale "en" and number system "latn" since this is what the number formatting routines use as placeholders.

This function is intended for use at compile time only and is used to help optimise the generation of transliteration functions.

known_rbnf_locale_name(locale_name, config)

Returns either the locale name (if its known and has an rbnf configuration) or false.

known_rbnf_locale_names(config)

This function is deprecated. Use Cldr.Locale.Loader.known_rbnf_locale_names/1.
@spec known_rbnf_locale_names(t()) :: [Cldr.Locale.locale_name()]

Returns a list of all locales that have RBNF data and that are configured and available in the CLDR repository.

known_territories()

Returns a list of atoms representing the territories known to Cldr.

Example

iex> Cldr.Config.known_territories()
[:"001", :"002", :"003", :"005", :"009", :"011", :"013", :"014", :"015", :"017",
 :"018", :"019", :"021", :"029", :"030", :"034", :"035", :"039", :"053", :"054",
 :"057", :"061", :"142", :"143", :"145", :"150", :"151", :"154", :"155", :"202",
 :"419", :AC, :AD, :AE, :AF, :AG, :AI, :AL, :AM, :AO, :AQ, :AR, :AS, :AT, :AU,
 :AW, :AX, :AZ, :BA, :BB, :BD, :BE, :BF, :BG, :BH, :BI, :BJ, :BL, :BM, :BN, :BO,
 :BQ, :BR, :BS, :BT, :BV, :BW, :BY, :BZ, :CA, :CC, :CD, :CF, :CG, :CH, :CI, :CK,
 :CL, :CM, :CN, :CO, :CP, :CQ, :CR, :CU, :CV, :CW, :CX, :CY, :CZ, :DE, :DG, :DJ,
 :DK, :DM, :DO, :DZ, :EA, :EC, :EE, :EG, :EH, :ER, :ES, :ET, :EU, :EZ, :FI, :FJ,
 :FK, :FM, :FO, :FR, :GA, :GB, :GD, :GE, :GF, :GG, :GH, :GI, :GL, :GM, :GN, :GP,
 :GQ, :GR, :GS, :GT, :GU, :GW, :GY, :HK, :HM, :HN, :HR, :HT, :HU, :IC, :ID, :IE,
 :IL, :IM, :IN, :IO, :IQ, :IR, :IS, :IT, :JE, :JM, :JO, :JP, :KE, :KG, :KH, :KI,
 :KM, :KN, :KP, :KR, :KW, :KY, :KZ, :LA, :LB, :LC, :LI, :LK, :LR, :LS, :LT, :LU,
 :LV, :LY, :MA, :MC, :MD, :ME, :MF, :MG, :MH, :MK, :ML, :MM, :MN, :MO, :MP, :MQ,
 :MR, :MS, :MT, :MU, :MV, :MW, :MX, :MY, :MZ, :NA, :NC, :NE, :NF, :NG, :NI, :NL,
 :NO, :NP, :NR, :NU, :NZ, :OM, :PA, :PE, :PF, :PG, :PH, :PK, :PL, :PM, :PN, :PR,
 :PS, :PT, :PW, :PY, :QA, :QO, :RE, :RO, :RS, :RU, :RW, :SA, :SB, :SC, :SD, :SE,
 :SG, :SH, :SI, :SJ, :SK, :SL, :SM, :SN, :SO, :SR, :SS, :ST, :SV, :SX, :SY, :SZ,
 :TA, :TC, :TD, :TF, :TG, :TH, :TJ, :TK, :TL, :TM, :TN, :TO, :TR, :TT, :TV, :TW,
 :TZ, :UA, :UG, :UM, :UN, :US, :UY, :UZ, :VA, :VC, :VE, :VG, :VI, :VN, :VU, :WF,
 :WS, :XK, :YE, :YT, :ZA, :ZM, :ZW]

language_data()

Return the language data that maps valid territories and scripts

language_tag(locale_name)

@spec language_tag(Cldr.Locale.locale_name()) :: Cldr.LanguageTag.t() | no_return()

Return the saved language tag for the given locale name.

language_tag_for_territory()

Return the mapping from a territory to a language tag.

This is used to derive a locale from a territory.

likely_subtags()

Returns the likely subtags map which maps a locale string to %LaguageTag{} representing the likely subtags for that locale string

locale_filename(locale)

Returns the filename that contains the json representation of a locale.

locale_name_from_posix(name)

Transforms a locale name from the Posix format to the Cldr format

locale_name_to_posix(name)

Transforms a locale name from the CLDR format to the Posix format

locale_path(locale, config)

@spec locale_path(Cldr.Locale.locale_name() | String.t(), Cldr.backend() | t()) ::
  {:ok, String.t()} | {:error, :not_found}

Returns the location of the json data for a locale

Arguments

Returns

  • {:ok, path} or

  • {:error, :not_found}

locale_path!(locale, config)

@spec locale_path!(String.t(), Cldr.backend() | t()) :: String.t() | no_return()

Returns the location of the json data for a locale

Arguments

Returns

  • path or

  • raises an exception

maybe_add_fallback_locales(config)

Add the fallback locales to a list of configured locales

measurement_systems()

Return a list of measurement systems

merge_locales_with_default(config)

normalize_plural_rules(rules)

number_symbols_for(locale_name, config)

Get the number symbol definitions for a locale

number_symbols_for(locale, number_system, config)

number_symbols_for!(locale_name, config)

Get the number symbol definitions for a locale or raises if an error

number_symbols_for!(locale_name, number_system, config)

number_system_for(locale_name, number_system, config)

@spec number_system_for(Cldr.Locale.locale_name(), number_system(), t()) ::
  {:ok, map()} | {:error, {module(), String.t()}}

Returns the number system for a given locale and number system name.

Example

iex> Cldr.Config.number_system_for(:th, :thai, %Cldr.Config{locales: ["th", "de"]})
{:ok, %{digits: "๐๑๒๓๔๕๖๗๘๙", type: :numeric}}

number_system_names_for(locale_name, config)

@spec number_system_names_for(Cldr.Locale.locale_name(), t()) ::
  {:ok, [atom(), ...]} | {:error, {module(), String.t()}}

Returns the number system names for a locale

Example

iex> Cldr.Config.number_system_names_for(:th, %Cldr.Config{locales: ["en", "th"]})
{:ok, [:latn, :thai]}

number_system_types_for(locale_name, config)

Returns the number system types for a locale

number_systems_for(locale_name, config)

@spec number_systems_for(Cldr.Locale.locale_name(), t()) ::
  {:ok, map()} | {:error, {module(), String.t()}}

Returns the number systems for a locale

Example

iex> Cldr.Config.number_systems_for(:en, %Cldr.Config{locales: ["en", "de"]})
{:ok, %{default: :latn, native: :latn}}

number_systems_for!(locale_name, config)

@spec number_systems_for!(Cldr.Locale.locale_name(), t()) :: map() | no_return()

Returns the number systems for a locale or raises if there is an error

Example

iex> Cldr.Config.number_systems_for!(:de, %Cldr.Config{locales: ["en", "de"]})
%{default: :latn, native: :latn}

parent_locales()

Returns a map of locale names to its parent locale name.

Note that these mappings only exist where the normal inheritance doesn't apply.

plural_ranges()

Return a map of plural ranges

raise_if_otp_app_not_loaded!(config)

requested_locale_names(config)

@spec requested_locale_names(t()) :: [Cldr.Locale.locale_name()]

Returns a list of all configured locales.

The list contains locales configured both in Gettext and specified in the mix.exs configuration file as well as the default locale.

required_modules()

@spec required_modules() :: [String.t()]

Identifies the top level keys in the consolidated locale file.

These keys represent difference dimensions of content in the CLDR repository and serve three purposes:

  1. To structure the content in the locale file

  2. To provide a rudimentary way to validate that some json represents a valid locale file

root_locale_name()

source_data_dir()

Return the directory where Cldr stores its source core data,

This directory should not be expected to be available other than when developing Cldr since it points to a source directory.

These are the json files that result from the normalization of the original CLDR data.

split_currency_metadata(arg)

system_name_from(number_system, locale_name, backend)

@spec system_name_from(
  String.t(),
  Cldr.Locale.locale_name() | Cldr.LanguageTag.t(),
  t() | Cldr.backend()
) :: {:ok, atom()} | {:error, {module(), String.t()}}

Returns a number system name for a given locale and number system reference.

Arguments

Number systems can be referenced in one of two ways:

  • As a number system type such as :default, :native, :traditional and :finance. This allows references to a number system for a locale in a consistent fashion for a given use

  • With the number system name directly, such as :latn, :arab or any name returned by Cldr.known_number_systems/0

This function dereferences the supplied system_name and returns the actual system name.

Examples

iex> Cldr.Config.system_name_from(:default, :en, TestBackend.Cldr)
{:ok, :latn}

iex> Cldr.Config.system_name_from("latn", :en, TestBackend.Cldr)
{:ok, :latn}

iex> Cldr.Config.system_name_from(:native, :en, TestBackend.Cldr)
{:ok, :latn}

iex> Cldr.Config.system_name_from(:nope, :en, TestBackend.Cldr)
{
  :error,
  {Cldr.UnknownNumberSystemError, "The number system :nope is unknown"}
}

territories()

Returns a map of territory info for all territories known to CLDR.

The territory information is independent of the ex_cldr configuration.

Example

iex> Cldr.Config.territories()[:GB]
%{
  currency: [GBP: %{from: ~D[1694-07-27]}],
  gdp: 2925000000000,
  language_population: %{
    "ar" => %{population_percent: 0.3},
    "bn" => %{population_percent: 0.4},
    "cy" => %{official_status: "official_regional", population_percent: 1.3},
    "de" => %{population_percent: 9},
    "en" => %{official_status: "official", population_percent: 98},
    "en-Shaw" => %{population_percent: 0},
    "es" => %{population_percent: 8},
    "fr" => %{population_percent: 23},
    "ga" => %{official_status: "official_regional", population_percent: 0.15},
    "gd" => %{
      official_status: "official_regional",
      population_percent: 0.11,
      writing_percent: 5
    },
    "gu" => %{population_percent: 2.9},
    "it" => %{population_percent: 0.2},
    "kw" => %{population_percent: 0.003},
    "lt" => %{population_percent: 0.2},
    "pa" => %{population_percent: 3.6},
    "pl" => %{population_percent: 4},
    "pt" => %{population_percent: 0.2},
    "sco" => %{population_percent: 2.5, writing_percent: 5},
    "so" => %{population_percent: 0.2},
    "ta" => %{population_percent: 3.2},
    "tr" => %{population_percent: 0.2},
    "ur" => %{population_percent: 3.5},
    "zh-Hant" => %{population_percent: 0.3}
  },
  literacy_percent: 99,
  measurement_system: %{
    default: :uksystem,
    paper_size: :a4,
    temperature: :uksystem
  },
  population: 65761100
}

territory(territory)

@spec territory(Cldr.Locale.territory_reference() | String.t()) ::
  %{} | {:error, {module(), String.t()}}

Get territory info for a specific territory.

  • territory is a string, atom or language_tag representation of a territory code in the list returned by Cldr.known_territories

Returns:

  • A map of the territory information or
  • {:error, reason}

Example

iex> Cldr.Config.territory "au"
%{
  currency: [AUD: %{from: ~D[1966-02-14]}],
  gdp: 1248000000000,
  language_population: %{
    "en" => %{official_status: "de_facto_official", population_percent: 96},
    "it" => %{population_percent: 1.9},
    "wbp" => %{population_percent: 0.0098},
    "zh-Hant" => %{population_percent: 2.1},
    "hnj" => %{population_percent: 0.0086}
  },
  literacy_percent: 99,
  measurement_system: %{default: :metric, paper_size: :a4, temperature: :metric},
  population: 25466500
}

iex> Cldr.Config.territory "abc"
{:error, {Cldr.UnknownTerritoryError, "The territory \"abc\" is unknown"}}

territory_containers()

Returns a map of territory containers

territory_containment()

Returns a map of territory containment

territory_currency_data()

@spec territory_currency_data() :: map()

Returns the currency mapping data for territories.

territory_info()

This function is deprecated. Use Cldr.Config.territories/0.

See Cldr.Config.territories/0.

territory_info(territory)

This function is deprecated. Use Cldr.Config.territories/1.

See Cldr.Config.territory/1.

territory_subdivision_containment()

Return a mapping between a subdivision and its containing parents

territory_subdivisions()

Return the territory subdivisions

unicode_script_to_subtag_mapping()

Returns a mapping from Unicode script names to the respective subtag used in BCP 47 language tags.

units()

Returns unit conversion data,

Example

iex> Cldr.Config.units() |> get_in([:conversions, :quart])
%{
  base_unit: :cubic_meter,
  factor: "0.000946352946",
  offset: 0,
  systems: [:ussystem]
}

unknown_locale_names(config)

@spec unknown_locale_names(t()) :: [Cldr.Locale.locale_name()]

Returns a list of all locales that are configured but not available in the CLDR repository.

validity(type)

Return a map of validity data for a given type.

The types are :languages, :scripts, :territories, :subdivisions, :variants :units, :u, and :t

version()

Returns the version string of the CLDR data repository

week_info()

This function is deprecated. Use Cldr.Config.weeks/0.

See Cldr.Config.weeks/0.

weeks()

Returns the data that defines start and end of calendar weeks, weekends and years