Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect formatting of kilojoules #48

Open
fekle opened this issue Nov 20, 2024 · 4 comments
Open

Incorrect formatting of kilojoules #48

fekle opened this issue Nov 20, 2024 · 4 comments

Comments

@fekle
Copy link

fekle commented Nov 20, 2024

Hi there,

I'm using this great library to format various units correctly for different languages, and for almost everything I have tested, the unit names are correct.

However, what I've noticed is that there is an issue with the abbreviation for kilojoules. In many languages (and SI, as far as I know), the shorthand is kJ with an uppercase J, but cldr_units always returns kj:

> Cldr.Unit.to_string!(32, unit: :kilojoule, locale: "de", style: :short)
"32 kj"
> Cldr.Unit.to_string!(32, unit: :kilojoule, locale: "en", style: :short)
"32 kj"
> Cldr.Unit.to_string!(32, unit: :kilojoule, locale: "fr", style: :short)
"32 kj"
> Cldr.Unit.to_string!(32, unit: :kilojoule, locale: nil, style: :short)
"32 kj"

As far as I can tell, everything is configured correctly on my end, and the CLDR dataset also specifies "kJ." Is there anything I'm missing here?

Also, I hope I'm posting this issue in the correct repo; it is not entirely clear to me if the unit name formatting is done in this lib or the base CLDR library.

Some more information:

OS: macos 15.1

elixir:  1.17.3-otp-27
erlang:  27.1.2

ex_cldr: "2.40.1"
ex_cldr_calendars: "1.26.2"
ex_cldr_currencies: "2.16.3"
ex_cldr_dates_times: "2.20.3"
ex_cldr_languages: "0.3.3"
ex_cldr_lists: "2.11.1"
ex_cldr_numbers: "2.33.4"
ex_cldr_plugs: "1.3.3"
ex_cldr_territories: "2.9.0"
ex_cldr_units: "3.17.2"

Thank you for this great library, and let me know if there is anything I can do to help or if you need more information!

@kipcole9
Copy link
Collaborator

Yes, that does look like a bug - and a strange one. I'll see if I can resolve it my day (sun just rising in UTC+11)

@fekle
Copy link
Author

fekle commented Nov 20, 2024

Thank you!

I found a few more oddities and created a small Minimal Reproduction project here: https://github.com/fekle/ex_cldr_units_repro. I hope this helps!

Specifically, Cldr.Unit.display_name does not work for kilojoules, and the formatting of bytes and bits seems odd - see test/ex_cldr_units_repro_test.exs in the linked repo.

Greetings from UTC+1 ;)

@kipcole9
Copy link
Collaborator

Thanks @fekle, I'm still investigating - will do my best to get this resolved by Monday latest.

@fekle
Copy link
Author

fekle commented Nov 21, 2024

Thanks, and no stress!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants