-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add ordinalization for locales with simple pattern #1109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find! 👏🏻
CHANGELOG.md
Outdated
- Add ordinalization for many locales (be, bs, cs, da, eo, et, fa, fi, hr, hu, is, ka, | ||
lb, lt, lv, mk, nb, ne, nn, pl, sk, sl, sq, sr, sw, tr) #1109 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Can you please add |
@pouyaemami But en-CA doesn't have a “simple” pattern (as defined in this PR), does it? |
Ah, I think I missed the point of this PR. You're right, this isn't what I was hoping for. My issue is that I get this error: |
According to CLDR, a lot of locales use the same ordinalisation pattern for all numbers:
https://github.com/unicode-org/cldr/blob/12380e8/common/supplemental/ordinals.xml#L16-L18
Of these locales, the majority inherit from the simple rules defined in root.xml:
https://github.com/unicode-org/cldr/blob/12380e8/common/rbnf/root.xml#L698-L703
The rule just says that a number is ordinalised by adding a trailing period (aka ordinal dot), just like we currently do for German:
https://github.com/svenfuchs/rails-i18n/blob/master/rails/ordinals/de.rb
In fact, the rules for German are so simple, so we don't have to use Ruby files but can just use YAML files like in
rails/locales/
. Also, there was a bug in the existing definitions forde-AT
,de-CH
andde-DE
– they all define rules forde
, not for each region-specific locale.Based on the tool from #1107 I used
Cldr::Export.export(components: [Rbnf], …)
to generaterbnf.yml
for all rails-i18n locales whose CLDR counterpart includes an rbnf.xml. In order to get proper inheritance from root, I applied this patch: ruby-i18n/ruby-cldr#257.I then found all rails-i18n locales whose ordinal rules were identical to the rules defined in root.xml. For each of these locales I generated an identical file in
rails/ordinals
.