ruby-cldr 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +56 -46
  4. data/README.textile +6 -0
  5. data/Rakefile +2 -2
  6. data/VERSION +1 -1
  7. data/lib/cldr/download.rb +1 -1
  8. data/lib/cldr/export.rb +70 -16
  9. data/lib/cldr/export/data.rb +31 -21
  10. data/lib/cldr/export/data/aliases.rb +47 -0
  11. data/lib/cldr/export/data/base.rb +4 -0
  12. data/lib/cldr/export/data/characters.rb +30 -0
  13. data/lib/cldr/export/data/fields.rb +60 -0
  14. data/lib/cldr/export/data/languages.rb +1 -1
  15. data/lib/cldr/export/data/likely_subtags.rb +29 -0
  16. data/lib/cldr/export/data/numbers.rb +48 -6
  17. data/lib/cldr/export/data/parent_locales.rb +23 -0
  18. data/lib/cldr/export/data/plural_rules.rb +70 -0
  19. data/lib/cldr/export/data/rbnf.rb +12 -4
  20. data/lib/cldr/export/data/region_currencies.rb +45 -0
  21. data/lib/cldr/export/data/segments_root.rb +13 -3
  22. data/lib/cldr/export/data/territories.rb +1 -1
  23. data/lib/cldr/export/data/territories_containment.rb +30 -0
  24. data/lib/cldr/export/data/timezones.rb +18 -2
  25. data/lib/cldr/export/data/transforms.rb +76 -0
  26. data/lib/cldr/export/data/variables.rb +42 -0
  27. data/lib/cldr/export/yaml.rb +5 -21
  28. data/lib/cldr/thor.rb +2 -2
  29. data/test/export/data/calendars_test.rb +85 -51
  30. data/test/export/data/currencies_test.rb +29 -25
  31. data/test/export/data/languages_test.rb +69 -51
  32. data/test/export/data/numbers_test.rb +61 -62
  33. data/test/export/data/plurals_test.rb +4 -3
  34. data/test/export/data/territories_containment_test.rb +10 -0
  35. data/test/export/data/territories_test.rb +12 -5
  36. data/test/export/data/timezones_test.rb +5 -8
  37. data/test/export_test.rb +57 -5
  38. data/test/format/time_test.rb +5 -5
  39. metadata +40 -29
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ module Cldr
4
+ module Export
5
+ module Data
6
+ class Transforms < Base
7
+
8
+ attr_reader :transform_file
9
+
10
+ def initialize(transform_file)
11
+ super(nil) # no locale
12
+ @transform_file = transform_file
13
+ update(:transforms => transforms)
14
+ end
15
+
16
+ private
17
+
18
+ def transforms
19
+ doc.xpath("supplementalData/transforms/transform").map do |transform_node|
20
+ {
21
+ :source => transform_node.attribute("source").value,
22
+ :target => transform_node.attribute("target").value,
23
+ :variant => get_variant(transform_node),
24
+ :direction => transform_node.attribute("direction").value,
25
+ :rules => rules(transform_node)
26
+ }
27
+ end
28
+ end
29
+
30
+ def get_variant(node)
31
+ if attrib = node.attribute("variant")
32
+ attrib.value
33
+ end
34
+ end
35
+
36
+ def rules(transform_node)
37
+ rules = fix_rule_wrapping(
38
+ doc.xpath("#{transform_node.path}/tRule").flat_map do |rule_node|
39
+ fix_rule(rule_node.content).split("\n").map(&:strip)
40
+ end
41
+ )
42
+
43
+ rules.reject do |rule|
44
+ rule.strip.empty? || rule.strip.start_with?('#')
45
+ end
46
+ end
47
+
48
+ def fix_rule_wrapping(rules)
49
+ wrap = false
50
+
51
+ rules.each_with_object([]) do |rule, ret|
52
+ if wrap
53
+ ret.last.sub!(/\\\z/, rule)
54
+ else
55
+ ret << rule
56
+ end
57
+
58
+ wrap = rule.end_with?('\\')
59
+ end
60
+ end
61
+
62
+ def fix_rule(rule)
63
+ rule.
64
+ gsub("←", '<').
65
+ gsub("→", '>').
66
+ gsub("↔", '<>')
67
+ end
68
+
69
+ def path
70
+ transform_file
71
+ end
72
+
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,42 @@
1
+ module Cldr
2
+ module Export
3
+ module Data
4
+ class Variables < Base
5
+
6
+ # only these variables will be exported
7
+ VARIABLE_IDS = %w($grandfathered $language $territory $script $variant)
8
+
9
+ def initialize
10
+ super(nil)
11
+ update(:variables => variables)
12
+ end
13
+
14
+ private
15
+
16
+ def variables
17
+ doc.xpath('//validity/variable').inject({}) do |ret, variable|
18
+ name = variable.attribute('id').value
19
+ if VARIABLE_IDS.include?(name)
20
+ ret[fix_var_name(name)] = split_value_list(variable.text)
21
+ end
22
+ ret
23
+ end
24
+ end
25
+
26
+ def fix_var_name(var_name)
27
+ # remove leading dollar sign
28
+ var_name.sub(/\A\$/, '')
29
+ end
30
+
31
+ def split_value_list(value_list)
32
+ value_list.strip.split(/[\s]+/)
33
+ end
34
+
35
+ def path
36
+ @path ||= "#{Cldr::Export::Data.dir}/supplemental/supplementalMetadata.xml"
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,11 +1,8 @@
1
- require 'ya2yaml'
1
+ require 'yaml'
2
2
 
3
3
  module Cldr
4
4
  module Export
5
- class Yaml < Ya2YAML
6
- def initialize
7
- super(:syck_compatible => true)
8
- end
5
+ class Yaml
9
6
 
10
7
  def export(locale, component, options = {})
11
8
  data = Export.data(component, locale, options)
@@ -19,22 +16,9 @@ module Cldr
19
16
  end
20
17
  end
21
18
 
22
- def yaml(data)
23
- emit(data, 1)[1..-1]
24
- end
25
-
26
- def emit(object, level = 1)
27
- result = object.is_a?(Symbol) ? object.inspect : super
28
- result.gsub(/(\s{1})(no):/i) { %(#{$1}"#{$2}":) } # FIXME fucking spaghetti code
29
- end
30
-
31
- def is_one_plain_line?(str)
32
- # removed REX_BOOL, REX_INT
33
- str !~ /^([\-\?:,\[\]\{\}\#&\*!\|>'"%@`\s]|---|\.\.\.)/ &&
34
- str !~ /[:\#\s\[\]\{\},]/ &&
35
- str !~ /#{REX_ANY_LB}/ &&
36
- str !~ /^(#{REX_FLOAT}|#{REX_MERGE}|#{REX_NULL}|#{REX_TIMESTAMP}|#{REX_VALUE})$/x
37
- end
19
+ def yaml(data)
20
+ data.to_yaml
21
+ end
38
22
  end
39
23
  end
40
24
  end
data/lib/cldr/thor.rb CHANGED
@@ -5,7 +5,7 @@ module Cldr
5
5
  class Thor < ::Thor
6
6
  namespace 'cldr'
7
7
 
8
- desc "download [--source=http://unicode.org/Public/cldr/24/core.zip] [--target=./vendor]",
8
+ desc "download [--source=http://unicode.org/Public/cldr/26/core.zip] [--target=./vendor]",
9
9
  "Download and extract CLDR data from source to target dir"
10
10
  method_options %w(source -s) => :string,
11
11
  %w(target -t) => :string
@@ -27,7 +27,7 @@ module Cldr
27
27
  Cldr::Export.export(options.dup.symbolize_keys) { putc '.' }
28
28
  puts
29
29
  end
30
-
30
+
31
31
  # TODO flatten task, e.g. flatten all plural locale files into one big file
32
32
  end
33
33
  end
@@ -11,15 +11,15 @@ class TestCldrDataCalendars < Test::Unit::TestCase
11
11
 
12
12
  test 'calendars months :de' do
13
13
  months = {
14
- :format => {
15
- :wide => { 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' },
16
- :abbreviated => { 1 => 'Jan.', 2 => 'Feb.', 3 => 'März', 4 => 'Apr.', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'Aug.', 9 => 'Sep.', 10 => 'Okt.', 11 => 'Nov.', 12 => 'Dez.' },
17
- :narrow => { 1 => 'J', 2 => 'F', 3 => 'M', 4 => 'A', 5 => 'M', 6 => 'J', 7 => 'J', 8 => 'A', 9 => 'S', 10 => 'O', 11 => 'N', 12 => 'D' },
14
+ :format => {
15
+ :abbreviated => { 1 => 'Jan.', 2 => 'Feb.', 3 => 'März', 4 => 'Apr.', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'Aug.', 9 => 'Sept.', 10 => 'Okt.', 11 => 'Nov.', 12 => 'Dez.' },
16
+ :narrow => { 1 => 'J', 2 => 'F', 3 => 'M', 4 => 'A', 5 => 'M', 6 => 'J', 7 => 'J', 8 => 'A', 9 => 'S', 10 => 'O', 11 => 'N', 12 => 'D' },
17
+ :wide => { 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' },
18
18
  },
19
19
  :'stand-alone' => {
20
- :abbreviated => { 1 => 'Jan', 2 => 'Feb', 3 => 'Mär', 4 => 'Apr', 5 => 'Mai', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Okt', 11 => 'Nov', 12 => 'Dez'},
21
- :narrow => { 1 => 'J', 2 => 'F', 3 => 'M', 4 => 'A', 5 => 'M', 6 => 'J', 7 => 'J', 8 => 'A', 9 => 'S', 10 => 'O', 11 => 'N', 12 => 'D' },
22
- :wide => { 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' },
20
+ :abbreviated => { 1 => 'Jan', 2 => 'Feb', 3 => 'Mär', 4 => 'Apr', 5 => 'Mai', 6 => 'Jun', 7 => 'Jul', 8 => 'Aug', 9 => 'Sep', 10 => 'Okt', 11 => 'Nov', 12 => 'Dez' },
21
+ :narrow => { 1 => 'J', 2 => 'F', 3 => 'M', 4 => 'A', 5 => 'M', 6 => 'J', 7 => 'J', 8 => 'A', 9 => 'S', 10 => 'O', 11 => 'N', 12 => 'D' },
22
+ :wide => { 1 => 'Januar', 2 => 'Februar', 3 => 'März', 4 => 'April', 5 => 'Mai', 6 => 'Juni', 7 => 'Juli', 8 => 'August', 9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Dezember' },
23
23
  }
24
24
  }
25
25
  assert_equal months, gregorian[:months]
@@ -27,17 +27,17 @@ class TestCldrDataCalendars < Test::Unit::TestCase
27
27
 
28
28
  test 'calendars days :de' do
29
29
  days = {
30
- :format => {
31
- :wide => { :sun => 'Sonntag', :mon => 'Montag', :tue => 'Dienstag', :wed => 'Mittwoch', :thu => 'Donnerstag', :fri => 'Freitag', :sat => 'Samstag' },
30
+ :format => {
31
+ :wide => { :sun => 'Sonntag', :mon => 'Montag', :tue => 'Dienstag', :wed => 'Mittwoch', :thu => 'Donnerstag', :fri => 'Freitag', :sat => 'Samstag' },
32
32
  :abbreviated => { :sun => 'So.', :mon => 'Mo.', :tue => 'Di.', :wed => 'Mi.', :thu => 'Do.', :fri => 'Fr.', :sat => 'Sa.' },
33
- :narrow => { :sun => 'S', :mon => 'M', :tue => 'D', :wed => 'M', :thu => 'D', :fri => 'F', :sat => 'S' },
34
- :short => { :sun => 'So.', :mon => 'Mo.', :tue => 'Di.', :wed => 'Mi.', :thu => 'Do.', :fri => 'Fr.', :sat => 'Sa.' }
33
+ :narrow => { :sun => 'S', :mon => 'M', :tue => 'D', :wed => 'M', :thu => 'D', :fri => 'F', :sat => 'S' },
34
+ :short => { :sun => 'So.', :mon => 'Mo.', :tue => 'Di.', :wed => 'Mi.', :thu => 'Do.', :fri => 'Fr.', :sat => 'Sa.' }
35
35
  },
36
36
  :'stand-alone' => {
37
37
  :abbreviated => { :sun => 'So', :mon => 'Mo', :tue => 'Di', :wed => 'Mi', :thu => 'Do', :fri => 'Fr', :sat => 'Sa' },
38
- :narrow => { :sun => 'S', :mon => 'M', :tue => 'D', :wed => 'M', :thu => 'D', :fri => 'F', :sat => 'S' },
39
- :short => { :sun => 'So.', :mon => 'Mo.', :tue => 'Di.', :wed => 'Mi.', :thu => 'Do.', :fri => 'Fr.', :sat => 'Sa.' },
40
- :wide => { :sun => 'Sonntag', :mon => 'Montag', :tue => 'Dienstag', :wed => 'Mittwoch', :thu => 'Donnerstag', :fri => 'Freitag', :sat => 'Samstag' },
38
+ :narrow => { :sun => 'S', :mon => 'M', :tue => 'D', :wed => 'M', :thu => 'D', :fri => 'F', :sat => 'S' },
39
+ :short => { :sun => 'So.', :mon => 'Mo.', :tue => 'Di.', :wed => 'Mi.', :thu => 'Do.', :fri => 'Fr.', :sat => 'Sa.' },
40
+ :wide => { :sun => 'Sonntag', :mon => 'Montag', :tue => 'Dienstag', :wed => 'Mittwoch', :thu => 'Donnerstag', :fri => 'Freitag', :sat => 'Samstag' },
41
41
  }
42
42
  }
43
43
  assert_equal days, gregorian[:days]
@@ -45,15 +45,15 @@ class TestCldrDataCalendars < Test::Unit::TestCase
45
45
 
46
46
  test 'calendars quarters :de' do
47
47
  quarters = {
48
- :format => {
49
- :wide => { 1 => "1. Quartal", 2 => "2. Quartal", 3 => "3. Quartal", 4 => "4. Quartal" },
50
- :narrow => { 1 => "1", 2 => "2", 3 => "3", 4 => "4" },
48
+ :format => {
49
+ :wide => { 1 => "1. Quartal", 2 => "2. Quartal", 3 => "3. Quartal", 4 => "4. Quartal" },
50
+ :narrow => { 1 => "1", 2 => "2", 3 => "3", 4 => "4" },
51
51
  :abbreviated => { 1 => "Q1", 2 => "Q2", 3 => "Q3", 4 => "Q4" }
52
52
  },
53
53
  :"stand-alone" => {
54
54
  :abbreviated => { 1 => "Q1", 2 => "Q2", 3 => "Q3", 4 => "Q4" },
55
- :narrow => { 1 => "1", 2 => "2", 3 => "3", 4 => "4" },
56
- :wide => { 1 => "1. Quartal", 2 => "2. Quartal", 3 => "3. Quartal", 4 => "4. Quartal" }
55
+ :narrow => { 1 => "1", 2 => "2", 3 => "3", 4 => "4" },
56
+ :wide => { 1 => "1. Quartal", 2 => "2. Quartal", 3 => "3. Quartal", 4 => "4. Quartal" }
57
57
  }
58
58
  }
59
59
  assert_equal quarters, gregorian[:quarters]
@@ -61,14 +61,15 @@ class TestCldrDataCalendars < Test::Unit::TestCase
61
61
 
62
62
  test 'calendars periods :de' do
63
63
  periods = {
64
- :afternoon => "nachmittags",
65
- :am => "vorm.",
66
- :earlyMorning => "morgens",
67
- :evening => "abends",
68
- :morning => "vormittags",
69
- :night => "nachts",
70
- :noon => "Mittag",
71
- :pm => "nachm."
64
+ :afternoon1=>"mittags",
65
+ :afternoon2=>"nachmittags",
66
+ :am=>"AM",
67
+ :evening1=>"abends",
68
+ :midnight=>"Mitternacht",
69
+ :morning1=>"morgens",
70
+ :morning2=>"vormittags",
71
+ :night1=>"nachts",
72
+ :pm=>"PM",
72
73
  }
73
74
  assert_equal periods, gregorian[:periods][:format][:wide]
74
75
  end
@@ -96,51 +97,84 @@ class TestCldrDataCalendars < Test::Unit::TestCase
96
97
 
97
98
  test 'calendars date formats :de' do
98
99
  formats = {
99
- :full => { :pattern => "EEEE, d. MMMM y" },
100
- :long => { :pattern => "d. MMMM y" },
101
- :medium => { :pattern => "dd.MM.y" },
102
- :short => { :pattern => "dd.MM.yy" }
100
+ :full => { :pattern => "EEEE, d. MMMM y" },
101
+ :long => { :pattern => "d. MMMM y" },
102
+ :medium => { :pattern => "dd.MM.y" },
103
+ :short => { :pattern => "dd.MM.yy" }
103
104
  }
104
105
  assert_equal formats, gregorian[:formats][:date]
105
106
  end
106
107
 
107
108
  test 'calendars time formats :de' do
108
109
  formats = {
109
- :full => { :pattern => "HH:mm:ss zzzz" },
110
- :long => { :pattern => "HH:mm:ss z" },
111
- :medium => { :pattern => "HH:mm:ss" },
112
- :short => { :pattern => "HH:mm" }
110
+ :full => { :pattern => "HH:mm:ss zzzz" },
111
+ :long => { :pattern => "HH:mm:ss z" },
112
+ :medium => { :pattern => "HH:mm:ss" },
113
+ :short => { :pattern => "HH:mm" }
113
114
  }
114
115
  assert_equal formats, gregorian[:formats][:time]
115
116
  end
116
117
 
117
118
  test 'calendars datetime formats :de' do
118
119
  formats = {
119
- :full => { :pattern => "{{date}} {{time}}"},
120
- :long => { :pattern => "{{date}} {{time}}"},
121
- :medium => { :pattern => "{{date}} {{time}}"},
122
- :short => { :pattern => "{{date}} {{time}}"}
120
+ :full => { :pattern => "{{date}} 'um' {{time}}" },
121
+ :long => { :pattern => "{{date}} 'um' {{time}}" },
122
+ :medium => { :pattern => "{{date}}, {{time}}" },
123
+ :short => { :pattern => "{{date}}, {{time}}" }
123
124
  }
124
125
  assert_equal formats, gregorian[:formats][:datetime]
125
126
  end
126
127
 
127
128
  test 'calendars fields :de' do
128
- fields = {
129
- :hour => "Stunde",
130
- :minute => "Minute",
131
- :second => "Sekunde",
132
- :day => "Tag",
133
- :month => "Monat",
134
- :year => "Jahr",
135
- :week => "Woche",
136
- :weekday => "Wochentag",
129
+ fields = { :day => "Tag",
130
+ :"day-narrow" => "Tag",
131
+ :"day-short" => "Tag",
132
+ :dayOfYear => "Tag des Jahres",
133
+ :"dayOfYear-narrow" => "T/J",
134
+ :"dayOfYear-short" => "Tag des Jahres",
137
135
  :dayperiod => "Tageshälfte",
138
- :era => "Epoche",
139
- :zone => "Zeitzone"
136
+ :"dayperiod-narrow" => "Tagesh.",
137
+ :"dayperiod-short" => "Tageshälfte",
138
+ :era => "Epoche",
139
+ :"era-narrow" => "E",
140
+ :"era-short" => "Epoche",
141
+ :hour => "Stunde",
142
+ :"hour-narrow" => "Std.",
143
+ :"hour-short" => "Std.",
144
+ :minute => "Minute",
145
+ :"minute-narrow" => "Min.",
146
+ :"minute-short" => "Min.",
147
+ :month => "Monat",
148
+ :"month-narrow" => "M",
149
+ :"month-short" => "Monat",
150
+ :quarter => "Quartal",
151
+ :"quarter-narrow" => "Q",
152
+ :"quarter-short" => "Quart.",
153
+ :second => "Sekunde",
154
+ :"second-narrow" => "Sek.",
155
+ :"second-short" => "Sek.",
156
+ :week => "Woche",
157
+ :"week-narrow" => "W",
158
+ :"week-short" => "Woche",
159
+ :weekOfMonth => "Woche des Monats",
160
+ :"weekOfMonth-narrow" => "Wo. des Monats",
161
+ :"weekOfMonth-short" => "W/M",
162
+ :weekday => "Wochentag",
163
+ :"weekday-narrow" => "Wochent.",
164
+ :"weekday-short" => "Wochentag",
165
+ :weekdayOfMonth => "Wochentag",
166
+ :"weekdayOfMonth-narrow" => "WT",
167
+ :"weekdayOfMonth-short" => "Wochentag",
168
+ :year => "Jahr",
169
+ :"year-narrow" => "J",
170
+ :"year-short" => "Jahr",
171
+ :zone => "Zeitzone",
172
+ :"zone-narrow" => "Zeitz.",
173
+ :"zone-short" => "Zeitzone",
140
174
  }
141
175
  assert_equal fields, gregorian[:fields]
142
176
  end
143
-
177
+
144
178
  test 'merged calendars for de-AT contains all date format and stand-alone name types' do
145
179
  assert_equal %w(abbreviated narrow wide), gregorian(:merged => true)[:months][:format].keys.map { |key| key.to_s }.sort
146
180
  assert_equal %w(abbreviated narrow wide), gregorian(:merged => true)[:months][:"stand-alone"].keys.map { |key| key.to_s }.sort
@@ -5,33 +5,37 @@ require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'
5
5
  class TestCldrCurrencies < Test::Unit::TestCase
6
6
  test 'currencies :de' do
7
7
  codes = [:ADP, :AED, :AFA, :AFN, :ALL, :AMD, :ANG, :AOA, :AOK, :AON, :AOR,
8
- :ARA, :ARP, :ARS, :ATS, :AUD, :AWG, :AZM, :AZN, :BAD, :BAM, :BBD,
9
- :BDT, :BEC, :BEF, :BEL, :BGL, :BGN, :BHD, :BIF, :BMD, :BND, :BOB,
10
- :BOP, :BOV, :BRB, :BRC, :BRE, :BRL, :BRN, :BRR, :BRZ, :BSD, :BTN,
11
- :BUK, :BWP, :BYB, :BYR, :BZD, :CAD, :CDF, :CHE, :CHF, :CHW, :CLF,
12
- :CLP, :CNY, :COP, :CRC, :CSD, :CSK, :CUC, :CUP, :CVE, :CYP, :CZK,
13
- :DDM, :DEM, :DJF, :DKK, :DOP, :DZD, :ECS, :ECV, :EEK, :EGP, :ERN,
14
- :ESA, :ESB, :ESP, :ETB, :EUR, :FIM, :FJD, :FKP, :FRF, :GBP, :GEK,
15
- :GEL, :GHC, :GHS, :GIP, :GMD, :GNF, :GNS, :GQE, :GRD, :GTQ, :GWE,
16
- :GWP, :GYD, :HKD, :HNL, :HRD, :HRK, :HTG, :HUF, :IDR, :IEP, :ILP,
17
- :ILS, :INR, :IQD, :IRR, :ISK, :ITL, :JMD, :JOD, :JPY, :KES, :KGS,
18
- :KHR, :KMF, :KPW, :KRW, :KWD, :KYD, :KZT, :LAK, :LBP, :LKR, :LRD,
19
- :LSL, :LTL, :LTT, :LUC, :LUF, :LUL, :LVL, :LVR, :LYD, :MAD, :MAF,
20
- :MDL, :MGA, :MGF, :MKD, :MLF, :MMK, :MNT, :MOP, :MRO, :MTL, :MTP,
21
- :MUR, :MVR, :MWK, :MXN, :MXP, :MXV, :MYR, :MZE, :MZM, :MZN, :NAD,
22
- :NGN, :NIC, :NIO, :NLG, :NOK, :NPR, :NZD, :OMR, :PAB, :PEI, :PEN,
23
- :PES, :PGK, :PHP, :PKR, :PLN, :PLZ, :PTE, :PYG, :QAR, :RHD, :ROL,
24
- :RON, :RSD, :RUB, :RUR, :RWF, :SAR, :SBD, :SCR, :SDD, :SDG, :SDP,
25
- :SEK, :SGD, :SHP, :SIT, :SKK, :SLL, :SOS, :SRD, :SRG, :SSP, :STD,
26
- :SUR, :SVC, :SYP, :SZL, :THB, :TJR, :TJS, :TMM, :TMT, :TND, :TOP,
27
- :TPE, :TRL, :TRY, :TTD, :TWD, :TZS, :UAH, :UAK, :UGS, :UGX, :USD,
28
- :USN, :USS, :UYP, :UYU, :UZS, :VEB, :VEF, :VND, :VUV, :WST, :XAF,
29
- :XAG, :XAU, :XBA, :XBB, :XBC, :XBD, :XCD, :XDR, :XEU, :XFO, :XFU,
30
- :XOF, :XPD, :XPF, :XPT, :XRE, :XTS, :XXX, :YDD, :YER, :YUD, :YUM,
31
- :YUN, :ZAL, :ZAR, :ZMK, :ZMW, :ZRN, :ZRZ, :ZWD, :ZWL, :ZWR]
8
+ :ARA, :ARP, :ARS, :ATS, :AUD, :AWG, :AZM, :AZN, :BAD, :BAM, :BBD,
9
+ :BDT, :BEC, :BEF, :BEL, :BGL, :BGN, :BHD, :BIF, :BMD, :BND, :BOB,
10
+ :BOP, :BOV, :BRB, :BRC, :BRE, :BRL, :BRN, :BRR, :BRZ, :BSD, :BTN,
11
+ :BUK, :BWP, :BYB, :BYR, :BZD, :CAD, :CDF, :CHE, :CHF, :CHW, :CLF,
12
+ :CLP, :CNY, :COP, :CRC, :CSD, :CSK, :CUC, :CUP, :CVE, :CYP, :CZK,
13
+ :DDM, :DEM, :DJF, :DKK, :DOP, :DZD, :ECS, :ECV, :EEK, :EGP, :ERN,
14
+ :ESA, :ESB, :ESP, :ETB, :EUR, :FIM, :FJD, :FKP, :FRF, :GBP, :GEK,
15
+ :GEL, :GHC, :GHS, :GIP, :GMD, :GNF, :GNS, :GQE, :GRD, :GTQ, :GWE,
16
+ :GWP, :GYD, :HKD, :HNL, :HRD, :HRK, :HTG, :HUF, :IDR, :IEP, :ILP,
17
+ :ILS, :INR, :IQD, :IRR, :ISK, :ITL, :JMD, :JOD, :JPY, :KES, :KGS,
18
+ :KHR, :KMF, :KPW, :KRW, :KWD, :KYD, :KZT, :LAK, :LBP, :LKR, :LRD,
19
+ :LSL, :LTL, :LTT, :LUC, :LUF, :LUL, :LVL, :LVR, :LYD, :MAD, :MAF,
20
+ :MDL, :MGA, :MGF, :MKD, :MLF, :MMK, :MNT, :MOP, :MRO, :MTL, :MTP,
21
+ :MUR, :MVR, :MWK, :MXN, :MXP, :MXV, :MYR, :MZE, :MZM, :MZN, :NAD,
22
+ :NGN, :NIC, :NIO, :NLG, :NOK, :NPR, :NZD, :OMR, :PAB, :PEI, :PEN,
23
+ :PES, :PGK, :PHP, :PKR, :PLN, :PLZ, :PTE, :PYG, :QAR, :RHD, :ROL,
24
+ :RON, :RSD, :RUB, :RUR, :RWF, :SAR, :SBD, :SCR, :SDD, :SDG, :SDP,
25
+ :SEK, :SGD, :SHP, :SIT, :SKK, :SLL, :SOS, :SRD, :SRG, :SSP, :STD,
26
+ :SUR, :SVC, :SYP, :SZL, :THB, :TJR, :TJS, :TMM, :TMT, :TND, :TOP,
27
+ :TPE, :TRL, :TRY, :TTD, :TWD, :TZS, :UAH, :UAK, :UGS, :UGX, :USD,
28
+ :USN, :USS, :UYP, :UYU, :UZS, :VEB, :VEF, :VND, :VUV, :WST, :XAF,
29
+ :XAG, :XAU, :XBA, :XBB, :XBC, :XBD, :XCD, :XDR, :XEU, :XFO, :XFU,
30
+ :XOF, :XPD, :XPF, :XPT, :XRE, :XTS, :XXX, :YDD, :YER, :YUD, :YUM,
31
+ :YUN, :ZAL, :ZAR, :ZMK, :ZMW, :ZRN, :ZRZ, :ZWD, :ZWL, :ZWR, :ALK,
32
+ :ARL, :ARM, :BAN, :BGM, :BGO, :BOL, :CLE, :CNX, :COU, :ILR, :ISJ,
33
+ :KRH, :KRO, :MCF, :MDC, :MKN, :MVP, :UYI, :VNN, :XSU, :XUA, :YUR,
34
+ :BYN, :CNH, :MRU, :STN, :VES]
32
35
 
33
36
  currencies = Cldr::Export::Data::Currencies.new('de')[:currencies]
34
- assert (currencies.keys - codes).empty? && (codes - currencies.keys).empty?
37
+ assert_empty codes - currencies.keys, "Unexpected missing currencies"
38
+ assert_empty currencies.keys - codes, "Unexpected extra currencies"
35
39
  assert_equal({ :one => 'Euro', :other => 'Euro', :symbol => '€' }, currencies[:EUR])
36
40
  end
37
41
 
@@ -4,62 +4,80 @@ require File.expand_path(File.join(File.dirname(__FILE__) + '/../../test_helper'
4
4
 
5
5
  class TestCldrDataLanguages < Test::Unit::TestCase
6
6
  test 'languages :de' do
7
- codes = [:aa, :ab, :ace, :ach, :ada, :ady, :ae, :af, :afa, :afh, :agq,
8
- :ain, :ak, :akk, :ale, :alg, :alt, :am, :an, :ang, :anp, :apa,
9
- :ar, :"ar-001", :arc, :arn, :arp, :art, :arw, :as, :asa, :ast,
10
- :ath, :aus, :av, :awa, :ay, :az, :ba, :bad, :bai, :bal, :ban,
11
- :bas, :bat, :bax, :bbj, :be, :bej, :bem, :ber, :bez, :bfd, :bg,
12
- :bh, :bho, :bi, :bik, :bin, :bkm, :bla, :bm, :bn, :bnt, :bo, :br,
13
- :bra, :brx, :bs, :bss, :btk, :bua, :bug, :bum, :byn, :byv, :ca,
14
- :cad, :cai, :car, :cau, :cay, :cch, :ce, :ceb, :cel, :cgg, :ch,
15
- :chb, :chg, :chk, :chm, :chn, :cho, :chp, :chr, :chy, :ckb, :cmc,
16
- :co, :cop, :cpe, :cpf, :cpp, :cr, :crh, :crp, :cs, :csb, :cu,
17
- :cus, :cv, :cy, :da, :dak, :dar, :dav, :day, :de, :"de-AT",
18
- :"de-CH", :del, :den, :dgr, :din, :dje, :doi, :dra, :dsb, :dua,
19
- :dum, :dv, :dyo, :dyu, :dz, :dzg, :ebu, :ee, :efi, :egy, :eka,
20
- :el, :elx, :en, :"en-AU", :"en-CA", :"en-GB", :"en-US", :enm, :eo,
21
- :es, :"es-419", :"es-ES", :"es-MX", :et, :eu, :ewo, :fa, :fan,
22
- :fat, :ff, :fi, :fil, :fiu, :fj, :fo, :fon, :fr, :"fr-CA", :"fr-CH",
23
- :frm, :fro, :frr, :frs, :fur, :fy, :ga, :gaa, :gay, :gba, :gd, :gem,
24
- :gez, :gil, :gl, :gmh, :gn, :goh, :gon, :gor, :got, :grb, :grc,
25
- :gsw, :gu, :guz, :gv, :gwi, :ha, :hai, :haw, :he, :hi, :hil, :him,
26
- :hit, :hmn, :ho, :hr, :hsb, :ht, :hu, :hup, :hy, :hz, :ia, :iba,
27
- :ibb, :id, :ie, :ig, :ii, :ijo, :ik, :ilo, :inc, :ine, :inh, :io,
28
- :ira, :iro, :is, :it, :iu, :ja, :jbo, :jmc, :jpr, :jrb, :jv, :ka,
29
- :kaa, :kab, :kac, :kaj, :kam, :kar, :kaw, :kbd, :kbl, :kcg, :kde,
30
- :kea, :kfo, :kg, :kha, :khi, :kho, :khq, :ki, :kj, :kk, :kkj, :kl,
31
- :kln, :km, :kmb, :kn, :ko, :kok, :kos, :kpe, :kr, :krc, :krl, :kro,
32
- :kru, :ks, :ksb, :ksf, :ksh, :ku, :kum, :kut, :kv, :kw, :ky, :la,
33
- :lad, :lag, :lah, :lam, :lb, :lez, :lg, :li, :ln, :lo, :lol, :loz,
34
- :lt, :lu, :lua, :lui, :lun, :luo, :lus, :luy, :lv, :mad, :maf, :mag,
35
- :mai, :mak, :man, :map, :mas, :mde, :mdf, :mdr, :men, :mer, :mfe,
36
- :mg, :mga, :mgh, :mh, :mi, :mic, :min, :mis, :mk, :mkh, :ml, :mn,
37
- :mnc, :mni, :mno, :mo, :moh, :mos, :mr, :ms, :mt, :mua, :mul, :mun,
38
- :mus, :mwl, :mwr, :my, :mye, :myn, :myv, :na, :nah, :nai, :nap, :naq,
39
- :nb, :nd, :nds, :ne, :new, :ng, :nia, :nic, :niu, :nl, :"nl-BE", :nmg,
40
- :nn, :nnh, :no, :nog, :non, :nqo, :nr, :nso, :nub, :nus, :nv, :nwc,
41
- :ny, :nym, :nyn, :nyo, :nzi, :oc, :oj, :om, :or, :os, :osa, :ota,
42
- :oto, :pa, :paa, :pag, :pal, :pam, :pap, :pau, :peo, :phi, :phn, :pi,
43
- :pl, :pon, :pra, :pro, :ps, :pt, :"pt-BR", :"pt-PT", :qu, :raj, :rap,
44
- :rar, :rm, :rn, :ro, :roa, :rof, :rom, :root, :ru, :rup, :rw, :rwk,
45
- :sa, :sad, :sah, :sai, :sal, :sam, :saq, :sas, :sat, :sba, :sbp, :sc,
46
- :scn, :sco, :sd, :se, :see, :seh, :sel, :sem, :ses, :sg, :sga, :sgn,
47
- :sh, :shi, :shn, :shu, :si, :sid, :sio, :sit, :sk, :sl, :sla, :sm,
48
- :sma, :smi, :smj, :smn, :sms, :sn, :snk, :so, :sog, :son, :sq, :sr,
49
- :srn, :srr, :ss, :ssa, :ssy, :st, :su, :suk, :sus, :sux, :sv, :sw,
50
- :swb, :swc, :syc, :syr, :ta, :tai, :te, :tem, :teo, :ter, :tet, :tg,
51
- :th, :ti, :tig, :tiv, :tk, :tkl, :tl, :tlh, :tli, :tmh, :tn, :to, :tog,
52
- :tpi, :tr, :trv, :ts, :tsi, :tt, :tum, :tup, :tut, :tvl, :tw, :twq,
53
- :ty, :tyv, :tzm, :udm, :ug, :uga, :uk, :umb, :und, :ur, :uz, :vai, :ve,
54
- :vi, :vo, :vot, :vun, :wa, :wae, :wak, :wal, :war, :was, :wen, :wo, :xal,
55
- :xh, :xog, :yao, :yap, :yav, :ybb, :yi, :yo, :ypk, :yue, :za, :zap, :zbl,
56
- :zen, :zgh, :zh, :"zh-Hans", :"zh-Hant", :znd, :zu, :zun, :zxx, :zza]
7
+ codes = [:aa, :ab, :ace, :ach, :ada, :ady, :ae, :aeb, :af,
8
+ :afh, :agq, :ain, :ak, :akk, :akz, :ale, :aln, :alt, :am,
9
+ :an, :ang, :anp, :ar, :"ar-001", :arc, :arn, :aro, :arp,
10
+ :arq, :ars, :arw, :ary, :arz, :as, :asa, :ase, :ast, :av,
11
+ :avk, :awa, :ay, :az, :ba, :bal, :ban, :bar, :bas, :bax,
12
+ :bbc, :bbj, :be, :bej, :bem, :bew, :bez, :bfd, :bfq, :bg,
13
+ :bgn, :bho, :bi, :bik, :bin, :bjn, :bkm, :bla, :bm, :bn,
14
+ :bo, :bpy, :bqi, :br, :bra, :brh, :brx, :bs, :bss, :bua,
15
+ :bug, :bum, :byn, :byv, :ca, :cad, :car, :cay, :cch, :ce,
16
+ :ceb, :cgg, :ch, :chb, :chg, :chk, :chm, :chn, :cho, :chp,
17
+ :chr, :chy, :ckb, :co, :cop, :cps, :cr, :crh, :crs, :cs,
18
+ :csb, :cu, :cv, :cy, :da, :dak, :dar, :dav, :de, :"de-AT",
19
+ :"de-CH", :del, :den, :dgr, :din, :dje, :doi, :dsb, :dtp,
20
+ :dua, :dum, :dv, :dyo, :dyu, :dz, :dzg, :ebu, :ee, :efi,
21
+ :egl, :egy, :eka, :el, :elx, :en, :"en-GB", :"en-US", :enm,
22
+ :eo, :es, :esu, :et, :eu, :ewo, :ext, :fa, :fan, :fat, :ff,
23
+ :fi, :fil, :fit, :fj, :fo, :fon, :fr, :frc, :frm, :fro,
24
+ :frp, :frr, :frs, :fur, :fy, :ga, :gaa, :gag, :gan, :gay,
25
+ :gba, :gbz, :gd, :gez, :gil, :gl, :glk, :gmh, :gn, :goh,
26
+ :gom, :gon, :gor, :got, :grb, :grc, :gsw, :gu, :guc, :gur,
27
+ :guz, :gv, :gwi, :ha, :hai, :hak, :haw, :he, :hi, :hif,
28
+ :hil, :hit, :hmn, :ho, :hr, :hsb, :hsn, :ht, :hu, :hup,
29
+ :hy, :hz, :ia, :iba, :ibb, :id, :ie, :ig, :ii, :ik, :ilo,
30
+ :inh, :io, :is, :it, :iu, :izh, :ja, :jam, :jbo, :jgo,
31
+ :jmc, :jpr, :jrb, :jut, :jv, :ka, :kaa, :kab, :kac,
32
+ :kaj, :kam, :kaw, :kbd, :kbl, :kcg, :kde, :kea, :ken,
33
+ :kfo, :kg, :kgp, :kha, :kho, :khq, :khw, :ki, :kiu, :kj,
34
+ :kk, :kkj, :kl, :kln, :km, :kmb, :kn, :ko, :koi, :kok,
35
+ :kos, :kpe, :kr, :krc, :kri, :krj, :krl, :kru, :ks, :ksb,
36
+ :ksf, :ksh, :ku, :kum, :kut, :kv, :kw, :ky, :la, :lad,
37
+ :lag, :lah, :lam, :lb, :lez, :lfn, :lg, :li, :lij, :liv,
38
+ :lkt, :lmo, :ln, :lo, :lol, :lou, :loz, :lrc, :lt, :ltg,
39
+ :lu, :lua, :lui, :lun, :luo, :lus, :luy, :lv, :lzh, :lzz,
40
+ :mad, :maf, :mag, :mai, :mak, :man, :mas, :mde, :mdf, :mdr,
41
+ :men, :mer, :mfe, :mg, :mga, :mgh, :mgo, :mh, :mi, :mic,
42
+ :min, :mk, :ml, :mn, :mnc, :mni, :moh, :mos, :mr, :mrj, :ms,
43
+ :mt, :mua, :mul, :mus, :mwl, :mwr, :mwv, :my, :mye, :myv,
44
+ :mzn, :na, :nan, :nap, :naq, :nb, :nd, :nds, :"nds-NL", :ne,
45
+ :new, :ng, :nia, :niu, :njo, :nl, :"nl-BE", :nmg, :nn, :nnh,
46
+ :no, :nog, :non, :nov, :nqo, :nr, :nso, :nus, :nv, :nwc, :ny,
47
+ :nym, :nyn, :nyo, :nzi, :oc, :oj, :om, :or, :os, :osa, :ota,
48
+ :pa, :pag, :pal, :pam, :pap, :pau, :pcd, :pcm, :pdc, :pdt,
49
+ :peo, :pfl, :phn, :pi, :pl, :pms, :pnt, :pon, :prg, :pro,
50
+ :ps, :pt, :qu, :quc, :qug, :raj, :rap, :rar, :rgn, :rif, :rm,
51
+ :rn, :ro, :"ro-MD", :rof, :rom, :root, :rtm, :ru, :rue, :rug,
52
+ :rup, :rw, :rwk, :sa, :sad, :sah, :sam, :saq, :sas, :sat, :saz,
53
+ :sba, :sbp, :sc, :scn, :sco, :sd, :sdc, :sdh, :se, :see, :seh,
54
+ :sei, :sel, :ses, :sg, :sga, :sgs, :sh, :shi, :shn, :shu, :si,
55
+ :sid, :sk, :sl, :sli, :sly, :sm, :sma, :smj, :smn, :sms, :sn,
56
+ :snk, :so, :sog, :sq, :sr, :srn, :srr, :ss, :ssy, :st, :stq,
57
+ :su, :suk, :sus, :sux, :sv, :sw, :"sw-CD", :swb, :syc, :syr,
58
+ :szl, :ta, :tcy, :te, :tem, :teo, :ter, :tet, :tg, :th, :ti,
59
+ :tig, :tiv, :tk, :tkl, :tkr, :tl, :tlh, :tli, :tly, :tmh,
60
+ :tn, :to, :tog, :tpi, :tr, :tru, :trv, :ts, :tsd, :tsi, :tt,
61
+ :ttt, :tum, :tvl, :tw, :twq, :ty, :tyv, :tzm, :udm, :ug, :uga,
62
+ :uk, :umb, :und, :ur, :uz, :vai, :ve, :vec, :vep, :vi, :vls,
63
+ :vmf, :vo, :vot, :vro, :vun, :wa, :wae, :wal, :war, :was,
64
+ :wbp, :wo, :wuu, :xal, :xh, :xmf, :xog, :yao, :yap, :yav,
65
+ :ybb, :yi, :yo, :yrl, :yue, :za, :zap, :zbl, :zea, :zen,
66
+ :zgh, :zh, :"zh-Hans", :"zh-Hant", :zu, :zun, :zxx, :zza]
57
67
 
58
68
  languages = Cldr::Export::Data::Languages.new('de')[:languages]
59
- assert (languages.keys - codes).empty? && (codes - languages.keys).empty?
69
+
70
+ assert_empty codes - languages.keys, "Unexpected missing languages"
71
+ assert_empty languages.keys - codes, "Unexpected extra languages"
60
72
  assert_equal('Deutsch', languages[:de])
61
73
  end
62
74
 
75
+ test 'languages does not overwrite long form with the short one' do
76
+ languages = Cldr::Export::Data::Languages.new(:en)[:languages]
77
+
78
+ assert_equal "American English", languages[:"en-US"]
79
+ end
80
+
63
81
  # Cldr::Export::Data.locales.each do |locale|
64
82
  # test "extract languages for #{locale}" do
65
83
  # assert_nothing_raised do