elixir-cldr / cldr

Elixir implementation of CLDR/ICU
Other
455 stars 34 forks source link

en_GB causing error #165

Closed gazzer82 closed 2 years ago

gazzer82 commented 2 years ago

I am trying to set a locale options, as well as the default locale to en_GB, but I get the following error when starting up the Phoenix project.

ex_cldr version 2.24.2

Here's my config:

defmodule Unipix.Cldr do use Cldr, locales: ["en_GB"], default_locale: "en_GB", providers: [Cldr.Number, Money] end

Generating Unipix.Cldr for 3 locales named ["en", "en-GB", "und"] with a default locale named "en_GB"

== Compilation error in file lib/unipix/cldr.ex ==
** (BadMapError) expected a map, got: nil
    (stdlib 3.16.1) :maps.put(:k, :v, nil)
    (stdlib 3.16.1) erl_eval.erl:252: :erl_eval.expr/5
    (stdlib 3.16.1) erl_eval.erl:893: :erl_eval.expr_list/6
    (stdlib 3.16.1) erl_eval.erl:408: :erl_eval.expr/5
    (ex_cldr 2.24.2) /Users/garethjeanne/Development/up/2021/unipix/lib/unipix/cldr.ex:1: Cldr.Backend.Compiler.__before_compile__/1

Any pointers on where I'm going wrong here, apologies if it's something obvious!

kipcole9 commented 2 years ago

Thanks for the report and sorry for the inconvenience. This definitely a bug. CLDR prefers bcp47 locale names but ex_cldr is intended to support both posix formatted (with underscores) and bcp47 (with dashes). The bug here is that it is not correctly doing so for :default_locale.

If you change the _ in en_GB to en-GB it will compile fine.

I'll fix the bug and publish a release in the next few hours.

kipcole9 commented 2 years ago

I have published ex_cldr version 2.25.0 which fixes this issues. Please run mix deps.update ex_cldr in your project. The changelog entry reads:

Bug Fixes

Enhancements

Thanks for the support and collaboration!

gazzer82 commented 2 years ago

Yup all working fine now, thanks so much for sorting so quickly, Merry Christmas!