# `Cldr`
[🔗](https://github.com/elixir-cldr/cldr/blob/v2.47.3/lib/cldr.ex#L1)

Cldr provides the core functions to retrieve and manage
the CLDR data that supports formatting and localisation.

This module provides the core functions to access formatted
CLDR data, set and retrieve a current locale and validate
certain core data types such as locales, currencies and
territories.

> #### `use Cldr` {: .info}
>
> When you `use Cldr`, a number of functions are generated
> that encapsulate CLDR data. A moodule that invokes `use Cldr`
> is referred to as a Cldr backend module.
>
> The functions in a Cldr backend module form the primary
> recommended API for `ex_cldr`.
>
> In additional, a number of additional modules
> may be generated with names that are prefixed by the name of
> the module in which `use Cldr` is invoked. The number and names
> of these additional modules is determined by the modules
> configured under the `:providers` option to `use Cldr`.
>
> It is not recommended that a module that invoke `use Cldr`
> define any other functions.
>
> See [the configuration guide](https://hexdocs.pm/ex_cldr/readme.html#configuration)
> for details on how to configure.

`Cldr` functionality is packaged into a several
libraries that each depend on this one.  These additional
libraries are:

* Plugs for setting the locale from an HTTP request: [ex_cldr_plugs](https://hex.pm/packages/ex_cldr_plugs)
* Number formatting: [ex_cldr_numbers](https://hex.pm/packages/ex_cldr_numbers)
* List formatting: [ex_cldr_lists](https://hex.pm/packages/ex_cldr_lists)
* Unit formatting: [ex_cldr_units](https://hex.pm/packages/ex_cldr_units)
* Date/Time/DateTime formatting: [ex_cldr_dates_times](https://hex.pm/packages/ex_cldr_dates_times)
* Route localization for Phoenix: [ex_cldr_routes](https://hex.pm/packages/ex_cldr_routes)
* Locale name localisation: [ex_cldr_locale_display](https://hex.pm/packages/ex_cldr_locale_display)
* HTML select helpers: [ex_cldr_html](https://hex.pm/packages/cldr_html)
* Calendars: [ex_cldr_calendars](https://hex.pm/packages/ex_cldr_calendars)
* Calendar formatting: [ex_cldr_calendars_format](https://hex.pm/packages/ex_cldr_calendars_format)
* Printf-like formatting: [ex_cldr_print](https://hex.pm/packages/ex_cldr_print)
* Collation: [ex_cldr_collation](https://hex.pm/packages/ex_cldr_collation)
* ICU Message formatting: [ex_cldr_messages](https://hex.pm/packages/ex_cldr_messages)
* Territories localization and information: [ex_cldr_territories](https://hex.pm/packages/ex_cldr_territories) by @Schultzer
* Languages localization: [ex_cldr_languages](https://hex.pm/packages/ex_cldr_languages) by @lostkobrakai

# `backend`

```elixir
@type backend() :: module()
```

# `all_locale_names`

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

Returns a list of all the locale names 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/1` and `known_locales/1`

# `available_locale_name?`

```elixir
@spec available_locale_name?(Cldr.Locale.locale_name() | Cldr.LanguageTag.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_name?/2`.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

## Examples

    iex> Cldr.available_locale_name?(:"en-AU")
    true

    iex> Cldr.available_locale_name?(:"en-SA")
    false

# `default_backend`

> This function is deprecated. Use default_backend!/0.

```elixir
@spec default_backend() :: backend() | no_return()
```

# `default_backend!`

Returns the configured default backend module.

The default backend can be set with
`Cldr.put_default_backend/1`.

Alternatively the default backend may be configured in
`config.exs` under the `ex_cldr` key as follows:

    config :ex_cldr,
      default_backend: <backend_module>

## Important Note

If this function is called and no default backend
is configured an exception will be raised.

# `default_locale`

Returns the configured global default `locale`.

The default locale can be set with
`Cldr.put_default_locale/1`.

Alternatively the default locale may be configured in
`config.exs` under the `ex_cldr` key as follows:

    config :ex_cldr,
      default_locale: <locale_name>

## Returns

* The default locale or

* Raises an exception if no default
  backend is configured

## Notes

`Cldr.default_locale/0` returns the system-wide
default locale.

## Example

    iex> Cldr.default_locale()
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "en-001",
      cldr_locale_name: :"en-001",
      language_subtags: [],
      extensions: %{},
      gettext_locale_name: "en_GB",
      language: "en",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :en,
      requested_locale_name: "en-001",
      script: :Latn,
      territory: :"001",
      transform: %{},
      language_variants: []
    }

# `default_locale`

```elixir
@spec default_locale(backend()) :: Cldr.LanguageTag.t()
```

Returns the global default `locale` for a
given backend.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.

## Returns

* The default locale for the backend.

## Example

    iex> Cldr.default_locale(TestBackend.Cldr)
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "en-001",
      cldr_locale_name: :"en-001",
      language_subtags: [],
      extensions: %{},
      gettext_locale_name: "en_GB",
      language: "en",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :en,
      requested_locale_name: "en-001",
      script: :Latn,
      territory: :"001",
      transform: %{},
      language_variants: []
    }

# `default_script`
*since 2.31.0* 

```elixir
@spec default_script() :: Cldr.Locale.script()
```

Returns the default script.

## Returns

* The default script which is `Latn`.

# `default_territory`

```elixir
@spec default_territory(backend()) :: atom()
```

Returns the default territory when a locale
does not specify one and none can be inferred.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module. The default is `Cldr.default_backend/0`

## Returns

* The default territory or

* Raises if no argument is supplied and there is no
  default backend configured

## Example

    iex> Cldr.default_territory(TestBackend.Cldr)
    :"001"

# `display_name`

```elixir
@spec display_name(term(), Keyword.t()) :: String.t()
```

Return a localised string suitable for
presentation purposes for structs that
implement the `Cldr.LanguageTag.DisplayName`
protocol.

The `Cldr.LanguageTag.DisplayName` protocol is
implemented in this library for
`t:Cldr.LanguageTag.t`.

Other CLDR-related libraries implement
the protocol for the types they support
such as `t:Cldr.Unit` and `t:Cldr.Currency`.

# `ellipsis`

```elixir
@spec ellipsis(String.t() | [String.t()], backend(), Keyword.t()) ::
  String.t() | {:error, {module(), String.t()}}
```

Add locale-specific ellipsis to a string.

## Arguments

* `string` is any `String.t` or a 2-element list
  of `String.t` between which the ellipsis is inserted.

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend/0`.
  Note that `Cldr.default_backend/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

* `options` is a keyword list of options.

## Options

* `:locale` is any valid locale name returned by `Cldr.known_locale_names/1`.
  The default is `Cldr.get_locale/0`

* `:location` determines where to place the ellipsis. The options are
  `:after` (the default for a single string argument), `:between` (the default
  and only valid location for an argument that is a list of two strings) and `:before`

* `:format` formats based upon whether the ellipsis
  is inserted between words or sentences. The valid options are
  `:word` or `:sentence`. The default is `:sentence`.

## Examples

    iex> Cldr.ellipsis "And furthermore"
    "And furthermore…"

    iex> Cldr.ellipsis ["And furthermore", "there is much to be done"], locale: "ja"
    "And furthermore…there is much to be done"

    iex> Cldr.ellipsis "And furthermore", format: :word
    "And furthermore …"

    iex> Cldr.ellipsis ["And furthermore", "there is much to be done"], locale: "ja", format: :word
    "And furthermore … there is much to be done"

# `flag`

Returns a unicode string representing a flag for a territory.

## Options

* `territory` is any valid territory code returned
  by `Cldr.known_territories/0` or a `Cldr.LanguageTag.t`

## Returns

* A string representing a flag or

* An empty string if the territory is valid but no
  unicode grapheme is defined. This is true for territories
  that are aggregate areas such as "the world" which is
  `:001`

* `{:error, {Cldr.UnknownTerritoryError, message}}`

## Notes

* If a `Cldr.LanguageTag.t` is provided, the territory is determined
  by `Cldr.Locale.territory_from_locale/1`

## Examples

    iex> Cldr.flag :AU
    "🇦🇺"

    iex> Cldr.flag :US
    "🇺🇸"

    iex> Cldr.flag "UN"
    "🇺🇳"

    iex> Cldr.flag(:UK)
    "🇬🇧"

    iex> Cldr.flag(:GB)
    "🇬🇧"

    iex> Cldr.flag(:UX)
    {:error, {Cldr.UnknownTerritoryError, "The territory :UX is unknown"}}

# `get_locale`

Return the `Cldr` locale for the
current process.

Note that the locale is set per-process. If the locale
is not set for the given process then:

* Return the global default locale
  which is defined under the `:ex_cldr` key in
  `config.exs`

* Or the system-wide default locale which is
  "en-001"

Note that if there is no locale set for the current
process then an error is not returned - a default locale
will be returned per the rules above.

## Example

    iex> Cldr.put_locale(TestBackend.Cldr.Locale.new!("pl"))
    iex> Cldr.get_locale()
    %Cldr.LanguageTag{
       backend: TestBackend.Cldr,
       canonical_locale_name: "pl",
       cldr_locale_name: :pl,
       extensions: %{},
       gettext_locale_name: nil,
       language: "pl",
       locale: %{},
       private_use: [],
       rbnf_locale_name: :pl,
       territory: :PL,
       requested_locale_name: "pl",
       script: :Latn,
       transform: %{},
       language_variants: []
     }

# `invalid_currency_error`

Returns an error tuple for an invalid currency.

## Arguments

* `currency` is any currency code **not** returned by `Cldr.known_currencies/0`

## Returns

* `{:error, {Cldr.InvalidCurrencyError, message}}`

## Examples

    iex> Cldr.invalid_currency_error("invalid")
    {Cldr.InvalidCurrencyError, "The currency \"invalid\" is invalid"}

# `is_locale_name`
*macro* 

# `known_calendars`

```elixir
@spec known_calendars() :: [atom(), ...]
```

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

## Example

    iex> Cldr.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`

```elixir
@spec known_currencies() :: [atom(), ...]
```

Returns a list of strings representing the currencies known to `Cldr`.

## Example

    iex> Cldr.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, :ZWG, :ZWL, :ZWR]

# `known_gettext_locale_name`

```elixir
@spec known_gettext_locale_name(String.t(), backend()) :: String.t() | false
```

Returns either the Gettext `locale_name` in Cldr format or
`false` based upon whether the locale name is configured in
`Gettext`.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_gettext_locale_name("en", TestBackend.Cldr)
    "en"

    iex> Cldr.known_gettext_locale_name("en-SA", TestBackend.Cldr)
    false

# `known_gettext_locale_name?`

```elixir
@spec known_gettext_locale_name?(String.t(), backend()) :: boolean()
```

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

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_gettext_locale_name?("en", TestBackend.Cldr)
    true

    iex> Cldr.known_gettext_locale_name?("!!", TestBackend.Cldr)
    false

# `known_gettext_locale_names`

```elixir
@spec known_gettext_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
```

Returns a list of Gettext locale names but in CLDR format with
underscore replaced by hyphen in order to facilitate comparisons
with Cldr locale names.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

# `known_locale_name`

```elixir
@spec known_locale_name(Cldr.Locale.locale_name() | String.t(), backend()) ::
  atom() | nil
```

Returns either the `locale_name` or `false` based upon
whether the locale name is configured in `Cldr`.

This is helpful when building a list of `or` expressions
to return the first known locale name from a list.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_locale_name(:"en-AU", TestBackend.Cldr)
    :"en-AU"

    iex> Cldr.known_locale_name(:"en-SA", TestBackend.Cldr)
    nil

# `known_locale_name?`

```elixir
@spec known_locale_name?(Cldr.Locale.locale_name(), backend()) :: boolean()
```

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

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_locale_name?(:en, TestBackend.Cldr)
    true

    iex> Cldr.known_locale_name?(:"!!", TestBackend.Cldr)
    false

# `known_locale_names`

```elixir
@spec known_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
```

Returns a list of the known locale names.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

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

# `known_number_system_types`

Returns a list of atoms representing the number systems types known to `Cldr`.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend/0`.
  Note that `Cldr.default_backend/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Example

    iex> Cldr.known_number_system_types(TestBackend.Cldr)
    [:default, :finance, :native, :traditional]

# `known_number_systems`

```elixir
@spec known_number_systems() :: [atom(), ...]
```

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

## Example

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

# `known_rbnf_locale_name`

```elixir
@spec known_rbnf_locale_name(Cldr.Locale.locale_name(), backend()) ::
  String.t() | false
```

Returns either the RBNF `locale_name` or `false` based upon
whether the locale name is configured in `Cldr`
and has RBNF rules defined.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_rbnf_locale_name(:en, TestBackend.Cldr)
    :en

    iex> Cldr.known_rbnf_locale_name(:"en-SA", TestBackend.Cldr)
    false

# `known_rbnf_locale_name?`

```elixir
@spec known_rbnf_locale_name?(Cldr.Locale.locale_name(), backend()) :: boolean()
```

Returns a boolean indicating if the specified locale
name is configured and available in Cldr and supports
rules based number formats (RBNF).

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Examples

    iex> Cldr.known_rbnf_locale_name?(:en, TestBackend.Cldr)
    true

    iex> Cldr.known_rbnf_locale_name?(:"!!", TestBackend.Cldr)
    false

# `known_rbnf_locale_names`

```elixir
@spec known_rbnf_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
```

Returns a list of locale names which have rules based number
formats (RBNF).

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module

# `known_territories`

```elixir
@spec known_territories() :: [atom(), ...]
```

Returns a list of the territories known to `Cldr`.

The territories codes are defined in [UN M.49](https://en.wikipedia.org/wiki/UN_M.49)
which defines both individual territories and enclosing territories. These enclosing
territories are defined for statistical purposes and do not relate to political
alignment.

For example, the territory `:"001"` is defined as "the world".

## Example

    iex> Cldr.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]

# `known_territory_subdivision_containment`

```elixir
@spec known_territory_subdivision_containment() :: %{
  required(subdivision_code :: Cldr.Locale.subdivision_code()) =&gt;
    contained_within :: [
      Cldr.Locale.territory_code() | Cldr.Locale.subdivision_code(),
      ...
    ]
}
```

Returns a map of territory subdivisions sith a list of
their parent subdivisions and region.

For a description of territory subdivisions see
`Cldr.known_territory_subdivisions/0`

# `known_territory_subdivisions`

```elixir
@spec known_territory_subdivisions() :: %{required(atom()) =&gt; list()}
```

Returns the map of territories and subdivisions and their
child subdivsions.

The subdivision codes designate a subdivision of a country
or region. They are called various names, such as a
state in the United States, or a province in Canada.

The codes in CLDR are based on ISO 3166-2 subdivision codes.
The ISO codes have a region code followed by a hyphen, then a
suffix consisting of 1..3 ASCII letters or digits.

The CLDR codes are designed to work in a unicode_locale_id
(BCP47), and are thus all lowercase, with no hyphen. For
example, the following are valid, and mean “English as
used in California, USA”.

    en-u-sd-usca
    en-US-u-sd-usca

CLDR has additional subdivision codes. These may start with
a 3-digit region code or use a suffix of 4 ASCII letters or
digits, so they will not collide with the ISO codes. Subdivision
codes for unknown values are the region code plus "zzzz", such as
"uszzzz" for an unknown subdivision of the US. Other codes may be
added for stability.

# `put_default_backend`

Set the default system-wide backend module.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.

## Returns

* `{:ok, backend}` or

* `{:error, {exception, reason}}`

# `put_default_locale`

Set's the system default locale.

The locale set here is the base level
system default equivalent to setting the
`:default_locale` key in `config.exs`.

## Arguments

* `locale` is a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`
  with a non-nil `:cldr_locale_name`.

## Returns

* `{:ok, locale}`

# `put_default_locale`

Sets the system default locale.

The locale set here is the base level
system default equivalent to setting the
`:default_locale` key in `config.exs`.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`.

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.

## Returns

* `{:ok, locale}` or

* `{:error, {exception, reason}}`

# `put_gettext_locale`

```elixir
@spec put_gettext_locale(Cldr.LanguageTag.t()) ::
  {:ok, binary() | nil} | {:error, {module(), String.t()}}
```

Set the current process's Gettext locale from a
`t:Cldr.LanguageTag`.

## Arguments

* `locale` is a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`.

## Returns

* `{:ok, gettext_locale_name}` or

* `{:error, {exception, reason}}`

## Behaviour

1. If the `locale.gettext_locale_name` is `nil` then an error
   is returned.

2. The `gettext` locale for the `gettext_backend` configured for the
   CLDR backend defined by the `t:Cldr.LanguageTag` is set.

## Examples

    iex> import Cldr.LanguageTag.Sigil
    iex> Cldr.put_gettext_locale(~l"en")
    {:ok, "en"}

    iex> import Cldr.LanguageTag.Sigil
    iex> Cldr.put_gettext_locale(~l"ru")
    {
      :error,
      {
        Cldr.UnknownLocaleError,
        "Locale TestBackend.Cldr.Locale.new!(\"ru-RU\") does not map to a known gettext locale name"
      }
    }

# `put_locale`

```elixir
@spec put_locale(backend(), Cldr.Locale.locale_reference()) ::
  {:ok, Cldr.LanguageTag.t()} | {:error, {module(), String.t()}}
```

Set the current process's locale for a specified backend or
for all backends.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module. The default is to set the locale
  for all backends.

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`
  or a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`. It may
  also be a map that contains the keys `"cldr_locale"` and `"cldr_backend"`
  which is the shape of a `Phoenix` and `Plug` session making it easy to
  set the locale from a session.

## Returns

* `{:ok, locale}`

## Behaviour

1. If no backend is provided and the locale is a `Cldr.LanguageTag.t`
then the the locale is set as the default for the current process

## Notes

See [rfc5646](https://tools.ietf.org/html/rfc5646) for the specification
of a language tag

## Examples

    iex> Cldr.put_locale(TestBackend.Cldr, "en")
    {:ok,
     %Cldr.LanguageTag{
       backend: TestBackend.Cldr,
       canonical_locale_name: "en",
       cldr_locale_name: :en,
       language_subtags: [],
       extensions: %{},
       gettext_locale_name: "en",
       language: "en",
       locale: %{},
       private_use: [],
       rbnf_locale_name: :en,
       requested_locale_name: "en",
       script: :Latn,
       territory: :US,
       transform: %{},
       language_variants: []
     }}

    iex> Cldr.put_locale(TestBackend.Cldr, "invalid-locale!")
    {:error, {Cldr.LanguageTag.ParseError,
      "Expected a BCP47 language tag. Could not parse the remaining \"!\" starting at position 15"}}

# `quote`

```elixir
@spec quote(String.t(), backend(), Keyword.t()) ::
  String.t() | {:error, {module(), String.t()}}
```

Add locale-specific quotation marks around a string.

## Arguments

* `string` is any valid Elixir string

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

* `options` is a keyword list of options

## Options

* `:locale` is any valid locale name returned by `Cldr.known_locale_names/1`.
  The default is `Cldr.get_locale/0`

* `:prefer` is one of `:default` or `:variant` with a default of `:default`.
  Some locales have alternative opening and closing quote marks and `:prefer`
  allows selecting a variant should one exist.

## Examples

    iex> Cldr.quote("Quoted String", MyApp.Cldr, locale: :en)
    "“Quoted String”"

    iex> Cldr.quote("Quoted String", MyApp.Cldr, prefer: :variant, locale: :de)
    "‚Quoted String‘"

    iex> Cldr.quote("Quoted String", MyApp.Cldr, locale: "ja")
    "「Quoted String」"

# `requested_locale_names`

```elixir
@spec requested_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
```

Returns a list of all requested locale names.

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

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

See also `known_locales/1` and `all_locales/0`.

# `territory_chain`

Return the territory fallback chain based upon
a locales territory (including `u` extension) and
territory containment definitions.

While CLDR also includes subdivisions in the
territory chain, this implementation does not
consider them.

## Arguments

* `territory` is either a binary or atom territory code
  or a `t:Cldr.LanguageTag`

## Returns

* `{:ok, list}` where `list` is a list of territories
  in decreasing order of containment (ie larger enclosing
  areas) or

* `{:error, {exception, reason}}` indicating an error

## Examples

    iex> Cldr.territory_chain "US"
    {:ok,  [:US, :UN, :"001"]}

    iex> Cldr.territory_chain :AU
    {:ok, [:AU, :UN, :"001"]}

    iex> {:ok, locale} = Cldr.validate_locale("en-US-u-rg-CAzzzz", MyApp.Cldr)
    iex> Cldr.territory_chain locale
    {:ok,  [:CA, :UN, :"001"]}

    iex> Cldr.territory_chain :"001"
    {:ok, [:"001"]}

# `territory_chain`

Return the territory fallback chain based upon
a locales territory (including `u` extension) and
territory containment definitions.

While CLDR also includes subdivisions in the
territory chain, this implementation does not
consider them.

## Arguments

* `locale` is a binary locale name

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.

## Returns

* `{:ok, list}` where `list` is a list of territories
  in decreasing order of containment (ie larger enclosing
  areas) or

* `{:error, {exception, reason}}` indicating an error

## Examples

    iex> Cldr.territory_chain "en-US-u-rg-CAzzzz", MyApp.Cldr
    {:ok,  [:CA, :UN, :"001"]}

# `territory_containment`

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

Returns a map of territories and the territories
within which they are contained.

# `the_world`

Returns the territory for the world

This is the outermost containment of
territories in CLDR.

CLDR does not yet consider non-terrestrial
territories.

# `to_string`

```elixir
@spec to_string(term()) :: String.t()
```

Return a localsed string for types
that implement the `Cldr.Chars` protocol.

The `Cldr.Chars` protocol is implemented in this
library for `t:Cldr.LanguageTag.t()`.

Other CLDR-related libraries implement
the protocol for the types they support
such as `Float`, `Integer`, `Decimal`,
`Money`, `Unit` and `List`.

# `unknown_calendar_error`

Returns an error tuple for an invalid calendar.

## Arguments

  * `calendar` is any calendar name **not** returned by `Cldr.known_calendars/0`

## Returns

* `{:error, {Cldr.UnknownCalendarError, message}}`

## Examples

    iex> Cldr.unknown_calendar_error("invalid")
    {Cldr.UnknownCalendarError, "The calendar name \"invalid\" is invalid"}

# `unknown_currency_error`

Returns an error tuple for an unknown currency.

## Arguments

* `currency` is any currency code **not** returned by `Cldr.known_currencies/0`

## Returns

* `{:error, {Cldr.UnknownCurrencyError, message}}`

## Examples

    iex> Cldr.unknown_currency_error("XAB")
    {Cldr.UnknownCurrencyError, "The currency \"XAB\" is unknown"}

# `unknown_locale_names`

```elixir
@spec unknown_locale_names(backend()) :: [Cldr.Locale.locale_name(), ...] | []
```

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

## Arguments

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

Since there is a compile-time exception raise if there are
any unknown locales this function should always
return an empty list.

# `unknown_number_system_error`

```elixir
@spec unknown_number_system_error(any()) ::
  {Cldr.UnknownNumberSystemError, String.t()}
```

Returns an error tuple for an unknown number system.

## Arguments

* `number_system` is any number system name **not** returned by `Cldr.known_number_systems/0`

## Returns

* `{:error, {Cldr.UnknownNumberSystemError, message}}`

## Examples

    iex> Cldr.unknown_number_system_error "invalid"
    {Cldr.UnknownNumberSystemError, "The number system \"invalid\" is invalid"}

    iex> Cldr.unknown_number_system_error :invalid
    {Cldr.UnknownNumberSystemError, "The number system :invalid is unknown"}

# `unknown_number_system_type_error`

```elixir
@spec unknown_number_system_type_error(any()) ::
  {Cldr.UnknownNumberSystemTypeError, String.t()}
```

Returns an error tuple for an unknown number system type.

## Options

* `number_system_type` is any number system type name **not** returned
  by `Cldr.known_number_system_types/1`

## Returns

* `{:error, {Cldr.UnknownNumberSystemTypeError, message}}`

## Examples

    iex> Cldr.unknown_number_system_type_error("invalid")
    {Cldr.UnknownNumberSystemTypeError, "The number system type \"invalid\" is invalid"}

    iex> Cldr.unknown_number_system_type_error(:invalid)
    {Cldr.UnknownNumberSystemTypeError, "The number system type :invalid is unknown"}

# `unknown_plural_type_error`

```elixir
@spec unknown_plural_type_error(any()) :: {Cldr.UnknownPluralTypeError, String.t()}
```

Returns an error tuple for an unknown plural type.

## Options

* `plural_type` is any unknown number system type

## Returns

* `{:error, {Cldr.UnknownPluralTypeError, message}}`

## Examples

    iex> Cldr.unknown_plural_type_error("invalid")
    {Cldr.UnknownPluralTypeError, "The plural type \"invalid\" is invalid"}

    iex> Cldr.unknown_plural_type_error(:invalid)
    {Cldr.UnknownPluralTypeError, "The plural type :invalid is unknown"}

# `unknown_script_error`
*since 2.23.0* 

```elixir
@spec unknown_script_error(any()) :: {Cldr.InvalidScriptError, String.t()}
```

Returns an error tuple for an invalid script.

## Arguments

* `script` is any script as a string or an atom

## Returns

* `{:error, {Cldr.InvalidScriptError, message}}`

## Examples

    iex> Cldr.unknown_script_error "invalid"
    {Cldr.InvalidScriptError, "The script \"invalid\" is invalid"}

    iex> Cldr.unknown_script_error :invalid
    {Cldr.InvalidScriptError, "The script :invalid is invalid"}

# `unknown_territory_error`

```elixir
@spec unknown_territory_error(any()) :: {Cldr.UnknownTerritoryError, String.t()}
```

Returns an error tuple for an unknown territory.

## Arguments

* `territory` is any territory code **not** returned by `Cldr.known_territories/0`

## Returns

* `{:error, {Cldr.UnknownTerritoryError, message}}`

## Examples

    iex> Cldr.unknown_territory_error("invalid")
    {Cldr.UnknownTerritoryError, "The territory \"invalid\" is unknown"}

# `validate_backend`

```elixir
@spec validate_backend(backend :: atom()) ::
  {:ok, atom()} | {:error, {atom(), String.t()}}
```

Validates that a module is a CLDR backend module.

## Arguments

* `backend` is any module name that may be a
  `Cldr` backend module.

## Returns

* `{:ok, backend}` is the module if a CLDR backend module or

* `{:error, {exception, reason}}` if the module is unknown or if
  the module is not a backend module.

## Examples

    iex> Cldr.validate_backend MyApp.Cldr
    {:ok, MyApp.Cldr}

    iex> Cldr.validate_backend :something_else
    {:error,
     {Cldr.UnknownBackendError,
      "The backend :something_else is not known or not a backend module."}}

# `validate_calendar`

```elixir
@spec validate_calendar(atom() | String.t()) ::
  {:ok, atom()} | {:error, {module(), String.t()}}
```

Normalise and validate a calendar name.

## Arguments

* `calendar` is any calendar name returned by `Cldr.known_calendars/0`

## Returns

* `{:ok, normalized_calendar_name}` or

* `{:error, {Cldr.UnknownCalendarError, message}}`

## Examples

    iex> Cldr.validate_calendar(:gregorian)
    {:ok, :gregorian}

    iex> Cldr.validate_calendar(:invalid)
    {:error, {Cldr.UnknownCalendarError, "The calendar name :invalid is invalid"}}

# `validate_currency`

Normalize and validate a currency code.

## Arguments

* `currency` is any ISO 4217 currency code as returned by `Cldr.known_currencies/0`
  or any valid private use ISO4217 code which is a three-letter alphabetic code that
  starts with "X".

## Returns

* `{:ok, normalized_currency_code}` or

* `{:error, {Cldr.UnknownCurrencyError, message}}`

## Examples

    iex> Cldr.validate_currency(:USD)
    {:ok, :USD}

    iex> Cldr.validate_currency("USD")
    {:ok, :USD}

    iex> Cldr.validate_currency(:XTC)
    {:ok, :XTC}

    iex> Cldr.validate_currency("xtc")
    {:ok, :XTC}

    iex> Cldr.validate_currency("ZZZ")
    {:error, {Cldr.UnknownCurrencyError, "The currency \"ZZZ\" is unknown"}}

    iex> Cldr.validate_currency("invalid")
    {:error, {Cldr.InvalidCurrencyError, "The currency \"invalid\" is invalid"}}

    iex> Cldr.validate_currency(:invalid)
    {:error, {Cldr.InvalidCurrencyError, "The currency :invalid is invalid"}}

# `validate_gettext_locale`

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

Normalise and validate a gettext locale name.

## Arguments

* `locale_name` is any valid locale name returned by `Cldr.known_locale_names/1`
  or a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend/0`.
  Note that `Cldr.default_backend/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Returns

* `{:ok, language_tag}`

* `{:error, reason}`

## Examples

# `validate_locale`

```elixir
@spec validate_locale(Cldr.Locale.locale_reference(), backend()) ::
  {:ok, Cldr.LanguageTag.t()} | {:error, {module(), String.t()}}
```

Normalise and validate a locale name.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`
  or a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Returns

* `{:ok, language_tag}`

* `{:error, reason}`

## Examples

    iex> Cldr.validate_locale(:en, TestBackend.Cldr)
    {:ok,
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "en",
      cldr_locale_name: :en,
      extensions: %{},
      gettext_locale_name: "en",
      language: "en",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :en,
      requested_locale_name: "en",
      script: :Latn,
      territory: :US,
      transform: %{},
      language_variants: []
    }}

    iex> Cldr.validate_locale(:af, TestBackend.Cldr)
    {:ok,
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "af",
      cldr_locale_name: :af,
      extensions: %{},
      gettext_locale_name: "en",
      language: "af",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :af,
      requested_locale_name: "af",
      script: :Latn,
      territory: :ZA,
      transform: %{},
      language_variants: []
    }}

    iex> Cldr.validate_locale("zzz", TestBackend.Cldr)
    {:error, {Cldr.InvalidLanguageError, "The language \"zzz\" is invalid"}}

# `validate_locale!`

```elixir
@spec validate_locale!(Cldr.Locale.locale_reference(), backend()) ::
  Cldr.LanguageTag.t() | no_return()
```

Normalise and validate a locale name or raises
an exception.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`
  or a `Cldr.LanguageTag` struct returned by `Cldr.Locale.new!/2`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend!/0`.
  Note that `Cldr.default_backend!/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Returns

* `language_tag` or

* raises an exception

## Examples

    iex> Cldr.validate_locale!(:en, TestBackend.Cldr)
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "en",
      cldr_locale_name: :en,
      extensions: %{},
      gettext_locale_name: "en",
      language: "en",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :en,
      requested_locale_name: "en",
      script: :Latn,
      territory: :US,
      transform: %{},
      language_variants: []
    }

    iex> Cldr.validate_locale!(:af, TestBackend.Cldr)
    %Cldr.LanguageTag{
      backend: TestBackend.Cldr,
      canonical_locale_name: "af",
      cldr_locale_name: :af,
      extensions: %{},
      gettext_locale_name: "en",
      language: "af",
      locale: %{},
      private_use: [],
      rbnf_locale_name: :af,
      requested_locale_name: "af",
      script: :Latn,
      territory: :ZA,
      transform: %{},
      language_variants: []
    }

    iex> Cldr.validate_locale!("zzz", TestBackend.Cldr)
    ** (Cldr.InvalidLanguageError) The language "zzz" is invalid

# `validate_measurement_system`

Normalise and validate a measurement system type.

## Arguments

* `measurement_system` is a known
  measurement system.

## Returns

* `{:ok, normalized_measurement_system}` or

* `{:error, {exception, message}}`

## Examples

    iex> Cldr.validate_measurement_system :metric
    {:ok, :metric}

    iex> Cldr.validate_measurement_system "ussystem"
    {:ok, :ussystem}

    iex> Cldr.validate_measurement_system "uksystem"
    {:ok, :uksystem}

    iex> Cldr.validate_measurement_system "something"
    {:error, {Cldr.UnknownMeasurementSystemError,
     "The measurement system \"something\" is invalid"}}

# `validate_number_system`

```elixir
@spec validate_number_system(atom() | String.t()) ::
  {:ok, atom()} | {:error, {module(), String.t()}}
```

Normalize and validate a number system name.

## Arguments

* `number_system` is any number system name returned by
  `Cldr.known_number_systems/0`.

## Returns

* `{:ok, normalized_number_system_name}` or

* `{:error, {exception, message}}`

## Examples

    iex> Cldr.validate_number_system :latn
    {:ok, :latn}

    iex> Cldr.validate_number_system :arab
    {:ok, :arab}

    iex> Cldr.validate_number_system "invalid"
    {
      :error,
      {Cldr.UnknownNumberSystemError, "The number system :invalid is unknown"}
    }

# `validate_number_system_type`

```elixir
@spec validate_number_system_type(String.t() | atom(), backend()) ::
  {:ok, atom()} | {:error, {module(), String.t()}}
```

Normalise and validate a number system type.

## Arguments

* `number_system_type` is any number system type returned by
  `Cldr.known_number_system_types/1`

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module.  The default is `Cldr.default_backend/0`.
  Note that `Cldr.default_backend/0` will raise an exception if
  no `:default_backend` is configured under the `:ex_cldr` key in
  `config.exs`.

## Returns

* `{:ok, normalized_number_system_type}` or

* `{:error, {exception, message}}`

## Examples

    iex> Cldr.validate_number_system_type(:default, TestBackend.Cldr)
    {:ok, :default}

    iex> Cldr.validate_number_system_type(:traditional, TestBackend.Cldr)
    {:ok, :traditional}

    iex> Cldr.validate_number_system_type(:latn, TestBackend.Cldr)
    {
      :error,
      {Cldr.UnknownNumberSystemTypeError, "The number system type :latn is unknown"}
    }

# `validate_plural_type`

```elixir
@spec validate_plural_type(atom() | String.t()) ::
  {:ok, Cldr.Number.PluralRule.plural_type()} | {:error, {module(), String.t()}}
```

Normalize and validate a plural type.

## Arguments

* `plural_type` is any plural type returned by
  `Cldr.Number.PluralRule.known_plural_types/0`

## Returns

* `{:ok, normalized_plural_type}` or

* `{:error, {exception, message}}`

## Examples

    iex> Cldr.validate_plural_type :few
    {:ok, :few}

    iex> Cldr.validate_plural_type "one"
    {:ok, :one}

    iex> Cldr.validate_plural_type "invalid"
    {
      :error,
      {Cldr.UnknownPluralTypeError, "The plural type :invalid is unknown"}
    }

# `validate_script`
*since 2.23.0* 

```elixir
@spec validate_script(Cldr.Locale.script() | String.t()) ::
  {:ok, atom()} | {:error, {module(), String.t()}}
```

Normalise and validate a script code.

## Arguments

* `script` is any script code as a binary
  or atom

## Returns:

* `{:ok, normalized_script_code}` or

* `{:error, {Cldr.UnknownscriptError, message}}`

## Examples

    iex> Cldr.validate_script("thai")
    {:ok, :Thai}

    iex> Cldr.validate_script("qaai")
    {:ok, :Zinh}

    iex> Cldr.validate_script(Cldr.Locale.new!("en", TestBackend.Cldr))
    {:ok, :Latn}

    iex> Cldr.validate_script("aaaa")
    {:error, {Cldr.InvalidScriptError, "The script \"aaaa\" is invalid"}}

    iex> Cldr.validate_script(%{})
    {:error, {Cldr.InvalidScriptError, "The script %{} is invalid"}}

# `validate_territory`

```elixir
@spec validate_territory(atom() | String.t()) ::
  {:ok, Cldr.Locale.territory_code()} | {:error, {module(), String.t()}}
```

Normalise and validate a territory code.

## Arguments

* `territory` is any territory code returned by `Cldr.known_territories/0`

## Returns:

* `{:ok, normalized_territory_code}` or

* `{:error, {Cldr.UnknownTerritoryError, message}}`

## Examples

    iex> Cldr.validate_territory("en")
    {:error, {Cldr.UnknownTerritoryError, "The territory \"en\" is unknown"}}

    iex> Cldr.validate_territory("gb")
    {:ok, :GB}

    iex> Cldr.validate_territory("001")
    {:ok, :"001"}

    iex> Cldr.validate_territory(Cldr.Locale.new!("en", TestBackend.Cldr))
    {:ok, :US}

    iex> Cldr.validate_territory(%{})
    {:error, {Cldr.UnknownTerritoryError, "The territory %{} is unknown"}}

# `validate_territory_subdivision`

Normalise and validate a territory subdivision code.

## Arguments

* `subdivision` is any territory code returned by `Cldr.known_territory_subdivisions/0`

## Returns:

* `{:ok, normalized_subdivision_code}` or

* `{:error, {Cldr.UnknownTerritoryError, message}}`

## Examples

# `version`

```elixir
@spec version() :: Version.t()
```

Returns the version of the CLDR repository.

## Example

    iex> Cldr.version()
    Version.parse!("48.0.0")

# `with_locale`
*since 2.32.0* 

```elixir
@spec with_locale(Cldr.Locale.locale_reference(), (-&gt; any())) :: any()
```

Execute a function with a locale ensuring that the
current locale is restored after the function.

## Arguments

* `locale` is any `t:Cldr.LanguageTag.t/0`, tyically returned
  by `Cldr.validate_locale/2`.

* `fun` is any 0-arity function or function capture.

## Returns

* The value returned by the function `fun/0` or

* raises an exception if the current locale cannot be
  identified.

# `with_locale`
*since 2.27.0* 

```elixir
@spec with_locale(Cldr.Locale.locale_reference(), backend(), (-&gt; any())) :: any()
```

Execute a function with a locale ensuring that the
current locale is restored after the function.

## Arguments

* `locale` is any valid locale name returned by `Cldr.known_locale_names/1`
  or a string locale name.

* `backend` is any module that includes `use Cldr` and therefore
  is a `Cldr` backend module. The default is `Cldr.default_backend!/0`.

* `fun` is any 0-arity function or function capture.

## Returns

* The value returned by the function `fun/0` or

* `{:error, {exception, reason}}` if the locale is invalid or

* raises an exception if the current locale cannot be
  identified.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
