How to coerce currency symbols with a character prefix? E.g. US$ not $ (even if "en" is the locale)

You might find the locale en-001 is closer to your needs. 001 is the UN M.49 code for “the world” so en-001 means “world English”. its not a great locale for typical use but it might suit in this case. Here are some examples:

iex> Money.to_string Money.new(:USD, 100), locale: "en-001"
{:ok, "US$100.00"}
iex> Money.to_string Money.new(:AUD, 100), locale: "en-001"
{:ok, "A$100.00"}
iex> Money.to_string Money.new(:THB, 100), locale: "en-001"
{:ok, "THB 100.00"}
iex> Money.to_string Money.new(:SGD, 100), locale: "en-001"
{:ok, "SGD 100.00"}

However if you are intending to localise your user experience then I would propose simply using Money.to_string money, currency_symbols: :iso since at least then the number formatting, symbol placement, digit grouping and so on will be appropriate for the users expectations.

1 Like