Comments (18)
This functionality is ready for review!
from ember-intl.
Question here -> formatjs/formatjs-extract-cldr-data#17
Here is what I discovered:
Because the CLDR is so large and contains so many different types of information, the JSON data here is grouped into packages by functionality. For each type of functionality, there are two available packages: The "modern" packages, which contain the set of locales listed as modern coverage targets by the CLDR subcomittee, and the "full" packages, which contain the complete set of locales, including those in the corresponding modern packages.
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.
from ember-intl.
@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.
from ember-intl.
@snewcomer FYI, master is now using the forks of intl-messageformat and intl-messageformat-parser scoped under the ember-intl org.
from ember-intl.
@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.
from ember-intl.
I'm highly interested in this feature and would be available for a PR. Do you already have some specific ideas in mind?
from ember-intl.
Yep same here! I'm looking to format numbers based on their compact form.
e.g. 123,000 in short form would be: en - 123K
ja - 12δΈ
https://github.com/unicode-cldr/cldr-numbers-modern/blob/master/main/ja/numbers.json
http://cldr.unicode.org/translation/number-patterns#TOC-Short-Numbers
I'm going to dig around over the next week or so.
from ember-intl.
@jasonmit So a couple of thoughts to start
- Question here -> formatjs/formatjs-extract-cldr-data#17
- Also, I'm not seeing
cldr-numbers-full
extracted in formatjs-extract-cldr-data. I think this may be step # 1 if you agree. e.g. the commit to add cldr-numbers-full was here but nothing was done with it.
from ember-intl.
@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.
from ember-intl.
@jasonmit Making some headway in extracting numbers-full. A few discussion points -
options
can specifyrelativeFields
here. I'm assuming we want arelativeNumbers
option that goes like this. What do you think?
Boolean for whether or not numbers should be extracted for the specified locales. The number data that's extracted is limited to the data required to support FormatJS' number formatting features, and it's organized in the shape described above.
- I'm assuming the data we want to extract is here and here and will offer
decimal_short/decimal_long
andcurrency_short/currency_long
options.
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.
from ember-intl.
options can specify relativeFields here. I'm assuming we want a relativeNumbers option that goes like this. What do you think?
Agreed and it would be configurable and maybe default to false for now until the next major version bump.
I'm assuming the data we want to extract is here and here and will offer decimal_short/decimal_long and currency_short/currency_long options.
Looks right to me!
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.
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 formatNumber()
{{format-number}}
as they're not really extendable in that way.
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 localeMatcher
is one we might not be able to support) then we warn that it was essentially ignored.
What are your thoughts?
from ember-intl.
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:
https://github.com/yahoo/intl-messageformat/blob/master/src/compiler.js#L90
https://github.com/yahoo/intl-messageformat-parser/blob/master/src/parser.pegjs#L76
from ember-intl.
@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?
from ember-intl.
@snewcomer sounds good to me
from ember-intl.
@jasonmit Ok after a lot of debugging, you were right. Need to update the parser and compiler and the format type will be shortNumber
. I'm thinking the compiler format
function will be our own function (nothing to do with Intl.NumberFormat
) where we normalize the number into a short number. What do you think?
Should we fork both pkgs and I can PR against those?
from ember-intl.
@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.
from ember-intl.
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.
from ember-intl.
Released as 4.0.0-beta.6!
from ember-intl.
Related Issues (20)
- When will there be another release? HOT 1
- Type issues from Registry HOT 6
- Type issues from -format-base.d.ts HOT 1
- bump typescript peer dependency to 5 HOT 3
- trailingZeroDisplay not working HOT 2
- FORMAT_ERROR when using the `Intl.RelativeTimeFormat` polyfill with `v6.0.0` of ember-intl HOT 3
- Double `intl.d.ts` cause type errors HOT 8
- Unexpected locale `en-us` after upgrade to ember-intl v6 HOT 6
- A simple, autogenerated integration test fails for a component using a translation in ember-intl 6.1.2 HOT 6
- Bundle size regression in v6.2.0 HOT 3
- Merge this into formatjs HOT 3
- Incompatible with native `ember-source` types HOT 5
- `allowEmpty` class property not respected in v6.3.1 HOT 1
- Extending helpers like FormatDate has braking changes between v6.2.2 and v6.3.0+ HOT 5
- Basic usage results in: You attempted to update `_locale` [...] infinite revalidation bugs, and performance issues, and is not supported. HOT 4
- How to use `publicOnly: true` in Embroider apps HOT 13
- v6 - Error on valid use of `many`: message cannot be parsed: Unknown plural category: many HOT 1
- Deleted
- Plans for v7 release
- Memory leak regression after upgrading to `>= 6.3.0` HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-intl.