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

Number formatting in foreign languages #1630

Closed
Omikhleia opened this issue Nov 26, 2022 · 1 comment · Fixed by #1632
Closed

Number formatting in foreign languages #1630

Omikhleia opened this issue Nov 26, 2022 · 1 comment · Fixed by #1632
Labels
enhancement Software improvement or feature request
Milestone

Comments

@Omikhleia
Copy link
Member

Omikhleia commented Nov 26, 2022

Why does SILE have the 3 "hacks" SU.formatNumber.en, SU.formatNumber.tr, SU.formatNumber.eo (with methods such as nth(), string() etc.) - not covering many languages, thus - while it also has ICU (via the "justenoughicu" wrapper to Lua) and could cover, with little efforts, a whole lot of languages with less ad hoc coding?

Just playing 5mn with ICU...

> print(icu.format_number_ext(1984, "en-US", 0)) -- 1984
> print(icu.format_number_ext(1984, "en-US", 1)) -- 1,984
> print(icu.format_number_ext(1984, "en-US", 5)) -- one thousand nine hundred eighty-four
> print(icu.format_number_ext(1984, "en-US", 6)) -- 1,984th

> print(icu.format_number_ext(1984, "fr-FR", 0)) -- 1984
> print(icu.format_number_ext(1984, "fr-FR", 1)) -- 1 984
> print(icu.format_number_ext(1984, "fr-FR", 5)) -- mille neuf cent quatre-vingt-quatre
> print(icu.format_number_ext(1984, "fr-FR", 6)) -- 1 984e

Or for useful purposes, not doubts 😁 :

> print(icu.format_number_ext(1984, "eo", 0)) = 1984
> print(icu.format_number_ext(1984, "eo", 1)) = 1 984
> print(icu.format_number_ext(1984, "eo", 5)) = mil naŭcent okdek kvar
> print(icu.format_number_ext(1984, "eo", 6)) = 1 984.

No, seriously:

>  print(icu.format_number_ext(1984, "sr-Cyrl", 5)) -- једна хиљаду деветсто осамдесет и четири
>  print(icu.format_number_ext(1984, "sr-Latn", 5)) -- jedna hiljadu devetsto osamdeset i četiri

Was there a good rationale not using ICU, and having those above-mentioned limited language hooks?
If not, should I make a PR?

EDIT: Of course eventually to unleash the power of the beast, we'd need using locales instead of the current use-my-country-code-as-a-language...

@Omikhleia Omikhleia changed the title Number formatting in foreign language Number formatting in foreign languages Nov 26, 2022
@alerque
Copy link
Member

alerque commented Nov 29, 2022

I think there was a good reason for not using ICU, but it no longer applies. Those hacks predate having the full ICU module as a dependency and have just kind of grown along with the source even since it's been available for a long time. There is no sane reason not to use it now.

@alerque alerque added the enhancement Software improvement or feature request label Nov 29, 2022
@alerque alerque added this to the v0.14.6 milestone Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Software improvement or feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants