-
Notifications
You must be signed in to change notification settings - Fork 603
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
Access to listPatterns? #602
Comments
Hi @Strate, The direct answer to your question is yes, you can access this data by using our cldr-data proxy Having said that, I assume you want to use that data to properly format lists (e.g., "Monday, Tuesday, Friday, and Saturday") and Globalize doesn't provide such List formatter at the moment. I believe the proper solution is implementing one. Would you be interested to do so? The first step is to define the API and a good baseline is: |
Hi @rxaviers, Accessing to I think I'm ready to start work on PR. I reviewed the tc39/ecma402#33 and I am confused. Usage algorithm is pretty clear and well described here: http://cldr.unicode.org/development/development-process/design-proposals/list-formatting, so, it should not be hard to implement. |
Exactly, that's why I answered to you question (please re-read it) and also added my assumption that you would want to use it as a formatter, which turns out to be correct. Please, correct me on any confusion.
Excellent. I'm replying to your other questions below...
Yeap, great reference. Also consider this up-to-date CLDR reference http://www.unicode.org/reports/tr35/tr35-general.html#ListPatterns.
I believe you can ignore any duration specific modifier for now. CLDR 24 has included this extra data for formatting durations. Note that the duration formatter re-uses this list formatter. "In addition, under , three new types of may be provided: "unit" (for use with long units), "unit-short", and "unit-narrow". These are intended to be used for constructing formats such as “2 hours, 5 minutes”, “2 hrs, 5 mins”, or “2h 5m”. If separate data for these are not provided, the standard will be used. [#5997]." (full changelog) Please, just let me know on any questions. |
The last one. New function will have this signature:
Is it ok? |
LGTM 👍, feel free to submit a PR with work in progress implementation for faster feedback and feel free to ask further questions if you have any. PS: I have considered proposing a change to your proposal by splitting
|
I implemented a small listPattern formatter, happy to adjust it to work well as a dependency for globalize as well: |
Hi @SlexAxton, this is great. I believe globalize could depend on it except for the precompiled version. I'm trying to figure out how globalize compiler could support it too... There's one thing (at least) that it would be good the compiler to do that is to slice CLDR to the minimum per usage basis. Compiler currently does that on other functionalities (e.g., date, number, etc) by listening to cldr-js get events (since cldr-js is used under the hoods in these modules to pick CLDR data) and then compiler can re-construct the minimum data slice. If cldr-listpattern used cldr-js too, we would be good. Although, I realize that a dependency on cldr-js could be overkill for simply accessing object properties. |
Is there any way to access listPatterns data from globalize?
If yes, how?
If no, which excpected api could be used? I think about something like:
The text was updated successfully, but these errors were encountered: