-
Notifications
You must be signed in to change notification settings - Fork 167
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
Format number with metric prefix #66
Comments
@gtimti we have discussed this feature extensibly. We have confirmed that we do have that data in CLDR, but it will require some rethinking about how we format numbers since today we are relying on the primitives (Intl.NumberFormat), which does not support this. It will take time. We can keep this issue open to track it. |
I'm highly interested in this feature and would be available for a PR. Do you already have some specific ideas in mind? |
Yep same here! I'm looking to format numbers based on their compact form. e.g. 123,000 in short form would be: en - https://github.com/unicode-cldr/cldr-numbers-modern/blob/master/main/ja/numbers.json I'm going to dig around over the next week or so. |
@jasonmit So a couple of thoughts to start
|
@snewcomer I know the primary author has moved on so I think the best course, to not impede progress, is leverage the fork and upstream changes. I'll do some digging on my end to see who has access to merge any changes we need in. |
Here is what I discovered:
I think it makes sense to continue to target the full locale data set since ember-intl will generally only bundle the locales being targeted by the app. Let me know if you discover a reason we should move to modern. |
@jasonmit So step 1 is for me to make a PR to the fork to extract the full numbers data set. I'll try to get up a PR by the end of the week. |
@jasonmit Making some headway in extracting numbers-full. A few discussion points -
Lmk if you think I'm somewhat on the right path. Still have to figure out specific implementation, but assuming we will have to build some type of formatter. |
Agreed and it would be configurable and maybe default to false for now until the next major version bump.
Looks right to me!
Yeah we'll need to sort that out. Unsure what the public API would be for this. I'm hesitant of having this be an extension of My initial feeling is that it will be its own service API and helper. OR we extend the API and it branches to a custom formatter when the new custom options are added. If additional options are provided that we cannot support (for example What are your thoughts? |
We'll also need to extend intl-messageformat compiler and parser to add a new format type if we want to support this API as a formatter in the ICU msg syntax. Relevant: |
@jasonmit I'm thinking that we first start a helper that simply takes a number that short formats a number. Just figure out the number extraction and formatting logic first. What do you think? |
@snewcomer sounds good to me |
@jasonmit Ok after a lot of debugging, you were right. Need to update the parser and compiler and the format type will be Should we fork both pkgs and I can PR against those? |
@snewcomer yes, a fork is needed and fine in this case. https://github.com/yahoo/intl-messageformat/issues/121 would help if the API supported registering external formatters. Probably a feature for another day. |
@snewcomer FYI, master is now using the forks of intl-messageformat and intl-messageformat-parser scoped under the ember-intl org. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This functionality is ready for review! |
Released as 4.0.0-beta.6! |
Is there any way to format number with SI prefix?
As an example how can I format value 12345 to 12.3k.
The text was updated successfully, but these errors were encountered: