Add ordinalization for locales with simple pattern#1109
Merged
pama merged 8 commits intosvenfuchs:masterfrom Feb 28, 2024
Merged
Add ordinalization for locales with simple pattern#1109pama merged 8 commits intosvenfuchs:masterfrom
pama merged 8 commits intosvenfuchs:masterfrom
Conversation
sunny
reviewed
Nov 8, 2023
Comment on lines
+3
to
+4
| - 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 |
Contributor
Author
|
@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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-CHandde-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.ymlfor 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.