Add ordinalization for locales with simple pattern #1109
Merged
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-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
.