View Source Cldr.Config (Cldr v2.34.1)

Provider configuration support functions for ex_cldr.

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

Link to this section 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 map 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 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

Returns the version string of the CLDR data repository

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

Link to this section Types

@type number_system() :: atom() | String.t()
@type t() :: %Cldr.Config{
  add_fallback_locales: boolean(),
  backend: module(),
  data_dir: String.t(),
  default_locale: String.t(),
  force_locale_download: boolean(),
  generate_docs: boolean(),
  gettext: module() | 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(), ...],
  supress_warnings: boolean()
}

Link to this section 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

@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.

Return the configured application name for cldr

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

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

See Cldr.Config.calendars/0.

Return the map of calendar preferences by territory

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

example

Example

iex> Cldr.Config.calendars |> Map.get(:gregorian)
%{calendar_system: "solar", eras: [[0, %{end: [0, 12, 31]}], [1, %{start: [1, 1, 1]}]]}
Link to this function

calendars_for_locale(locale_name, config)

View Source

Returns the calendars available for a given locale name

example

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]
Link to this function

canonical_name(locale_name)

View Source

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.

Return the root path of the cldr application

@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.

Link to this function

client_locales_dir(config)

View Source

Returns the directory where downloaded ex_cldr locales files are located.

Link to this function

configured_locale_names(config)

View Source
@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.

Link to this function

currencies_for(locale_name, config)

View Source

Returns the currency metadata for a locale.

arguments

Arguments

Link to this function

currencies_for!(locale_name, config)

View Source

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

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]}}

Return the system-wide default backend

Return the system-wide default locale.

Link to this function

default_locale_name(config)

View Source
@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"

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.

Link to this function

expand_locale_names(locale_names)

View Source
@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

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", :frr
]

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

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

Link to this function

fallback_chain(locale_name)

View Source

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

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

Link to this function

get_precompile_number_formats(config)

View Source

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

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

Return the configured Gettext module name or nil.

Link to this function

gettext_configured?(config)

View Source
@spec gettext_configured?(t()) :: boolean()

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

example

Example

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

gettext_default_locale(config)

View Source

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.

Link to this function

include_module_docs?(arg1)

View Source

Return the configured json lib

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

example

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]

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

example

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, :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]
Link to this function

known_gettext_locale_names(config)

View Source
@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.

Link to this function

known_locale_name(locale_name, config)

View Source

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

Link to this function

known_locale_names(config)

View Source
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.

Link to this function

known_number_system_types(config)

View Source

Returns the number system types that are known.

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

example

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]
Link to this function

known_number_systems_like(locale_name, number_system, config)

View Source
@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.

Link to this function

known_rbnf_locale_name(locale_name, config)

View Source

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

Link to this function

known_rbnf_locale_names(config)

View Source
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.

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

example

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, :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]

Return the language data that maps valid territories and scripts

Link to this function

language_tag(locale_name)

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

Return the saved language tag for the given locale name

Link to this function

language_tag_for_territory()

View Source

Return the mapping from a territory to a language tag.

This is used to derive a locale from a territory.

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.

Link to this function

locale_name_from_posix(name)

View Source

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

Link to this function

locale_name_to_posix(name)

View Source

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

Link to this function

locale_path(locale, config)

View Source
@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

Arguments

returns

Returns

  • {:ok, path} or

  • {:error, :not_found}

Link to this function

locale_path!(locale, config)

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

Returns the location of the json data for a locale

arguments

Arguments

returns

Returns

  • path or

  • raises an exception

Link to this function

maybe_add_fallback_locales(config)

View Source

Add the fallback locales to a list of configured locales

Return a map of measurement systems

Link to this function

merge_locales_with_default(config)

View Source
Link to this function

normalize_plural_rules(rules)

View Source
Link to this function

number_symbols_for(locale_name, config)

View Source

Get the number symbol definitions for a locale

Link to this function

number_symbols_for(locale, number_system, config)

View Source
Link to this function

number_symbols_for!(locale_name, config)

View Source

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

Link to this function

number_symbols_for!(locale_name, number_system, config)

View Source
Link to this function

number_system_for(locale_name, number_system, config)

View Source
@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

Example

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

number_system_names_for(locale_name, config)

View Source
@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

Example

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

number_system_types_for(locale_name, config)

View Source

Returns the number system types for a locale

Link to this function

number_systems_for(locale_name, config)

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

Returns the number systems for a locale

example

Example

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

number_systems_for!(locale_name, config)

View Source
@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

Example

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

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

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

Return a map of plural ranges

Link to this function

raise_if_otp_app_not_loaded!(config)

View Source
Link to this function

requested_locale_names(config)

View Source
@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.

@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

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.

Link to this function

system_name_from(number_system, locale_name, backend)

View Source
@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

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

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"}
}

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

The territory information is independent of the ex_cldr configuration.

example

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
}
@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

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"}}

Returns a map of territory containers

Returns a map of territory containment

Link to this function

territory_currency_data()

View Source
@spec territory_currency_data() :: map()

Returns the currency mapping data for territories.

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

See Cldr.Config.territories/0.

Link to this function

territory_info(territory)

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

See Cldr.Config.territory/1.

Link to this function

territory_subdivision_containment()

View Source

Return a mapping between a subdivision and its containing parents

Link to this function

territory_subdivisions()

View Source

Return the territory subdivisions

Returns unit conversion data,

example

Example

iex> Cldr.Config.units |> get_in([:conversions, :quart])
%{
  base_unit: :cubic_meter,
  factor: %{
    denominator: 13469199089641601294165159418313264309149074316066816,
    numerator: 12746616238742849396626455585282990375683527307233
  },
  offset: %{denominator: 1, numerator: 0},
  systems: [:ussystem]
}
Link to this function

unknown_locale_names(config)

View Source
@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.

Return a map of validity data

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

Returns the version string of the CLDR data repository

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

See Cldr.Config.weeks/0.

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