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

Support selectRange on PluralRules #3012

Closed
hsivonen opened this issue Jan 20, 2023 · 2 comments · Fixed by #4116
Closed

Support selectRange on PluralRules #3012

hsivonen opened this issue Jan 20, 2023 · 2 comments · Fixed by #4116
Assignees
Labels
C-pluralrules Component: Plural rules good first issue Good for newcomers help wanted Issue needs an assignee S-medium Size: Less than a week (larger bug fix or enhancement) U-ecma402 User: ECMA-402 compatibility

Comments

@hsivonen
Copy link
Member

Add support for tc39/proposal-intl-numberformat-v3#16 to ICU4X.

@hsivonen hsivonen added good first issue Good for newcomers help wanted Issue needs an assignee C-pluralrules Component: Plural rules labels Jan 20, 2023
@sffc sffc added the U-ecma402 User: ECMA-402 compatibility label Jan 25, 2023
@sffc sffc added the S-medium Size: Less than a week (larger bug fix or enhancement) label Feb 16, 2023
@sffc sffc added this to the Priority Backlog ⟨P3⟩ milestone Feb 16, 2023
@jedel1043
Copy link
Contributor

I was trying to implement PluralRules for Boa and I saw this API wasn't implemented.
I'll try to contribute this :)

@jedel1043 jedel1043 self-assigned this Sep 22, 2023
@sffc
Copy link
Member

sffc commented Sep 22, 2023

Cool! A few tips to get you started:

  1. We need to start consuming pluralRanges.json from CLDR-JSON:
    1. Add it here:
      "cldr-core/supplemental/plurals.json",
    2. Then run cargo make download-repo-sources
  2. Now you can add a data struct for the plural ranges into icu_plurals::provider. This is the most interesting step because you need to design a data structure that is correct, compact, and efficient. It is usually not a good idea to directly copy over the JSON structure. Note that we'll end up with one data hunk per locale, which is different than pluralRanges.json is structured.
  3. Once that is ready, add a transformer for the data in datagen/src/transform/cldr/plurals, then add the data key to plurals/data/config.json + datagen/src/registry.rs, then you can run cargo make testdata and cargo make bakeddata components/plurals to see it all transform before your eyes
  4. Finally, you can build the actual API for the feature. I'd suggest a new struct called PluralRanges in the icu_plurals crate.

Each of these steps can be done as a separate PR if you prefer.

This process is all documented in writing_a_data_struct_md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-pluralrules Component: Plural rules good first issue Good for newcomers help wanted Issue needs an assignee S-medium Size: Less than a week (larger bug fix or enhancement) U-ecma402 User: ECMA-402 compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants