Closed ghost closed 3 years ago
Thanks for the report and sorry for the inconvenience. I've just tried on master branch and it seems ok. Can you let me know what locale you are operating in? Perhaps that makes a difference since not all locales have all data for units yet (its a CLDR work in progress).
The error indicates that ex_cldr_units
couldn't find a unit pattern for
iex> Cldr.Unit.to_string!(1, [unit: :pascal, style: :short])
"1 Pa"
iex> MyApp.Cldr.Unit.to_string!(1, [unit: :pascal, style: :short])
"1 Pa"
Ah, right, sorry, forgot to mention that the default locale is set to de
.
iex(3)> App.Cldr.Unit.to_string!(1, [unit: "pascal", style: :narrow, locale: "en"])
"1Pa"
iex(4)> App.Cldr.Unit.to_string!(1, [unit: "pascal", style: :narrow, locale: "de"])
** (Cldr.Unit.NoPatternError) No format pattern was found for unit #Cldr.Unit<:pascal, 1> with grammatical case :nominative, gender :neuter and plural type :one
(ex_cldr_units 3.5.1) lib/cldr/unit/format.ex:675: Cldr.Unit.Format.get_unit_pattern!/6
(ex_cldr_units 3.5.1) lib/cldr/unit/format.ex:403: Cldr.Unit.Format.to_iolist/3
(ex_cldr_units 3.5.1) lib/cldr/unit/format.ex:194: Cldr.Unit.Format.to_string/3
(ex_cldr_units 3.5.1) lib/cldr/unit/format.ex:281: Cldr.Unit.Format.to_string!/3
Ahhhh, I suspect you are in the "de" locale given it refers to the :neuter
gender. And only locales "de" and "fr" currently have grammatical features in them.
Confirmed and can reproduce. I will explore further what I can do to mitigate the data gap. Should be able to resolve during your day and I'll publish an update when done.
Thank you!
I have published ex_cldr_units 3.5.2 that fixes the error with this commit. The changelog entry is:
Thanks for your patience and collaboration!
👋
I've just upgraded to the latest ExCLDR versions, and got the following error in one of the tests (which checks that all measurements used in the app can be "rendered"):
Without
:style
option it works as expected:I wonder if maybe
:style
has been replaced with some other option?Versions:
Thank you!