Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bb5b6a

Browse files
authored
Merge pull request #200 from ruby-i18n/movermeyer/sort_component_output
Sort output at component level
2 parents a2b4910 + dd5b2eb commit 9bb5b6a

25 files changed

+109
-103
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4040
- Inherit currency symbol from ancestor locale instead of using other versions, [#137](https://github.com/ruby-i18n/ruby-cldr/pull/137)
4141
- Export region validity data, [#179](https://github.com/ruby-i18n/ruby-cldr/pull/179)
4242
- `Layout` component no longer exports files unless they contain data, [#183](https://github.com/ruby-i18n/ruby-cldr/pull/183)
43+
- Sort the data at the component level, allowing components to specify their own sort orders, [#200](https://github.com/ruby-i18n/ruby-cldr/pull/200)
4344

4445
---
4546

lib/cldr/export/data/aliases.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Aliases < Base
1010
def initialize
1111
super(nil)
1212
update(aliases: aliases)
13+
deep_sort!
1314
end
1415

1516
private

lib/cldr/export/data/calendars/gregorian.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ class Gregorian < Base
88
def initialize(locale)
99
super
1010
update(
11-
months: contexts("month"),
11+
additional_formats: additional_formats,
1212
days: contexts("day"),
13-
eras: eras,
14-
quarters: contexts("quarter"),
15-
periods: contexts("dayPeriod", group: "alt"),
16-
fields: fields,
13+
eras: eras.deep_sort,
14+
fields: fields.deep_sort,
1715
formats: {
1816
date: formats("date"),
19-
time: formats("time"),
2017
datetime: formats("dateTime"),
18+
time: formats("time"),
2119
},
22-
additional_formats: additional_formats,
20+
months: contexts("month"),
21+
periods: contexts("dayPeriod", group: "alt").deep_sort,
22+
quarters: contexts("quarter"),
2323
)
2424
end
2525

@@ -52,8 +52,8 @@ def elements(node, kind, context, width, options = {})
5252
key = key =~ /^\d*$/ ? key.to_i : key.to_sym
5353

5454
if options[:group] && (found_group = node.attribute(options[:group]))
55-
result[found_group.value] ||= {}
56-
result[found_group.value][key] = node.content
55+
result[found_group.value.to_sym] ||= {}
56+
result[found_group.value.to_sym][key] = node.content
5757
else
5858
result[key] = node.content
5959
end

lib/cldr/export/data/country_codes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class CountryCodes < Base
77
def initialize
88
super(nil)
99
update(country_codes: country_codes)
10+
deep_sort!
1011
end
1112

1213
private

lib/cldr/export/data/currencies.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Currencies < Base
77
def initialize(locale)
88
super
99
update(currencies: currencies)
10+
deep_sort!
1011
end
1112

1213
private
@@ -29,11 +30,12 @@ def currency(node)
2930
end
3031

3132
symbols = select(node, "symbol")
32-
symbol = symbols.select { |child_node| child_node.attribute("alt").nil? }.first
3333
narrow_symbol = symbols.select { |child_node| child_node.attribute("alt")&.value == ("narrow") }.first
34-
data[:symbol] = symbol.content unless symbol.nil?
3534
data[:narrow_symbol] = narrow_symbol.content unless narrow_symbol.nil?
3635

36+
symbol = symbols.select { |child_node| child_node.attribute("alt").nil? }.first
37+
data[:symbol] = symbol.content unless symbol.nil?
38+
3739
data
3840
end
3941
end

lib/cldr/export/data/currency_digits_and_rounding.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def initialize
1616

1717
self[code.upcase.to_sym] = { digits: digits, rounding: rounding }
1818
end
19+
20+
deep_sort!
1921
end
2022
end
2123
end

lib/cldr/export/data/fields.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Fields < Base
77
def initialize(locale)
88
super
99
update(fields: fields)
10+
deep_sort!
1011
end
1112

1213
private

lib/cldr/export/data/likely_subtags.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class LikelySubtags < Base
77
def initialize
88
super(nil)
99
update(subtags: subtags)
10+
deep_sort!
1011
end
1112

1213
private

lib/cldr/export/data/lists.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class Lists < Base
77
def initialize(locale)
88
super
99
update(lists: lists)
10+
deep_sort!
1011
end
1112

1213
private

lib/cldr/export/data/metazones.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def initialize
2121
territory = node.attr("iso3166").to_sym
2222
result[territory] = node.content
2323
end
24+
25+
deep_sort!
2426
end
2527

2628
protected

0 commit comments

Comments
 (0)