Packages
ex_cldr_currencies
2.16.5
2.17.2
2.17.1
2.17.0
2.16.5
2.16.4
2.16.3
2.16.2
2.16.1
2.16.0
2.15.1
2.15.0
2.14.3
2.14.2
2.14.1
2.14.0
2.13.0
2.12.0
2.12.0-rc.1
2.12.0-rc.0
2.11.1
2.11.0
2.10.1
2.10.0
2.9.1
2.9.0
2.9.0-rc.1
2.9.0-rc.0
2.8.0
2.8.0-rc.0
2.7.0
2.6.2
2.6.1
2.6.0
2.5.0
2.5.0-rc.0
2.4.1
2.4.0
2.3.0
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.0
2.0.0-rc.0
1.1.1
1.1.0
1.0.0
0.1.0
Currency localization data encapsulation functions for the Common Locale Data Repository (CLDR).
Current section
Files
Jump to
Current section
Files
ex_cldr_currencies
README.md
README.md
# Cldr Currencies
Packages the currency definitions from [CLDR](http://cldr.unicode.org) into a set of functions
to return currency data.
## Installation
The package can be installed by adding `ex_cldr_currencies` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:ex_cldr_currencies, "~> 2.13"}
]
end
```
## Defining private use currencies
[ISO4217](https://en.wikipedia.org/wiki/ISO_4217) permits the creation of private use currencies. These are denoted by currencies that start with "X" followed by two characters. New currencies can be created with `Cldr.Currency.new/2` however in order to do so a supervisor must be started which maintains an `:ets` table that holds the custom currencies.
Since the currencies are stored in an `:ets` table they are transient and will be lost on application restart. It is the developers responsibility to define the required private use currencies on application restart.
### Starting the private use currency supervisor
The simplest way to start the private use currency supervisor is:
```elixir
iex> Cldr.Currency.start_link()
```
The preferred method however is to add the supervisor to your applications supervision tree. In your application module (ie the one that includes `use Application`):
```elixir
defmodule MyApp do
use Application
def start(_type, _args) do
# Start the service which maintains the
# :ets table that holds the private use currencies
children = [
Cldr.Currency
...
]
opts = [strategy: :one_for_one, name: MoneyTest.Supervisor]
Supervisor.start_link(children, opts)
# Load your custom currencies now that the
# Cldr.Currency genserver is running
# load_my_custom_currencies()
end
end
```