elixir-cldr/cldr_numbers

** (KeyError) key :symbol_count not found in: nil.

Closed this issue · 2 comments

We recently updated ex_cldr_numbers from 2.29.0 to 2.30.0 (along with ex_cldr from 2.34.2 to 2.36) and we're now seeing a raise with the following code:

MyApp.Cldr.Number.to_string(1234, currency: "USD", format: "US¤#,###")
** (KeyError) key :symbol_count not found in: nil. If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
    (ex_cldr_numbers 2.30.0) lib/cldr/number/format/options.ex:686: Cldr.Number.Format.Options.expand_currency_symbol/2
    (ex_cldr_numbers 2.30.0) lib/cldr/number/format/options.ex:130: Cldr.Number.Format.Options.validate_options/3
    (ex_cldr_numbers 2.30.0) lib/cldr/number.ex:457: Cldr.Number.to_string/3

Removing the US prefix in the format string works as you'd expect:

MyApp.Cldr.Number.to_string(1234, currency: "USD", format: "¤#,###")
{:ok, "$1,234.00"}

Are we holding it wrong? 😅

@simoncocking, apologies, that's sloppy of me. Fixed in ex_cldr_numbers version 2.30.1. The changelog entry reads:

Bug Fixes

  • Fixes currency formats where the currency symbol is neither the first or last token. Thanks to @simoncocking for the issue. Closes #35.

I added a test with your example so I believe its good to go. Of course please reopen the issue if you see otherwise.

Awesome, thanks @kipcole9 for the quick fix!