ruby-i18n / ruby-i18n/ruby-cldr

[CLDR v38+] Support / handle unit inflections

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
78
Forks
18
Avg merge
9d 8h
Merged PRs (30d)
3

Description

This PR added inflections to units, so entries in the data changed from:

<unit type="duration-day">
  <displayName>Tage</displayName>
  <unitPattern count="one">{0} Tag</unitPattern>
  <unitPattern count="other">{0} Tage</unitPattern>
  <perUnitPattern>{0} pro Tag</perUnitPattern>
</unit>

to

<unit type="duration-day">
  <gender>masculine</gender>
  <displayName>Tage</displayName>
  <unitPattern count="one">{0} Tag</unitPattern>
  <unitPattern count="one" case="accusative">{0} Tag</unitPattern>
  <unitPattern count="one" case="dative">{0} Tag</unitPattern>
  <unitPattern count="one" case="genitive">{0} Tages</unitPattern>
  <unitPattern count="other">{0} Tage</unitPattern>
  <unitPattern count="other" case="accusative">{0} Tage</unitPattern>
  <unitPattern count="other" case="dative">{0} Tagen</unitPattern>
  <unitPattern count="other" case="genitive">{0} Tage</unitPattern>
  <perUnitPattern>{0} pro Tag</perUnitPattern>
</unit>

Notably, there are now multiple values for each of the count attributes (one for each case). Previously, there was only the "nominative" case.

Using ruby-cldr with v38 gives a different behaviour than it did with v37, since this code returns whatever case happens to appear last in the file (in this case "genitive" in v38, "accusative" in v37).


As a first step, we should change the code to return the "nominative" case.
Longer term, we can look into ways to expose the other cases.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open lib/cldr/export/data/units.rb at the linked lines and inspect how unitPattern entries are selected. Change the first-step behavior so the nominative case is returned rather than whichever case appears last; done means CLDR v38 unit exports no longer depend on XML entry order.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
internationalization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.