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 #229

Open
wetneb opened this issue Jun 22, 2021 · 2 comments
Open

Number formatting #229

wetneb opened this issue Jun 22, 2021 · 2 comments

Comments

@wetneb
Copy link

wetneb commented Jun 22, 2021

I would find it nice if there was a way to format numbers according to the locale.
For instance, the number 1234.56 (as written in Javascript) should be rendered as 1,234.56 in English and 1 234,56 in French.

So it would be amazing if $.i18n('number-of-results', 1234.56) could render as There are 1,234.56 results in English and Il y a 1 234,56 résultats in French.

Apologies if this is already supported somehow, I couldn't figure it out looking at the readme.

The standard function Number.prototype.toLocaleString can of course be used but this has two downsides:

  • this will format the number according to the browser's locale, which might not be the same as the one used by this library
  • this means supplying this number as a string to jquery.i18n, so we probably break plural support by doing that (I haven't actually tried)
@santhoshtr
Copy link
Member

Currently it is not supported in this library. Note that we are not planning to add any new features to jquery.i18n but banana.i18n - a jquery independent modern js library will be the replacement.

What you described would be a good addition, I agree. We at wikimedia has this number formatting feature as part of a mediawiki dependent localization library. But the the digit separator patterns are coming from mediawikibackend. It is a large set of CLDR originated patterns for all supported languages. To support that we may need to copy that data as part of library and incorporate parsing and number separator loigc.

I will create a copy of this issue in banana-i18n repo

@wetneb
Copy link
Author

wetneb commented Jun 23, 2021

Thank you very much, feel free to close this one then!

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

No branches or pull requests

2 participants