i18n 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of i18n might be problematic. Click here for more details.

Files changed (62) hide show
  1. data/lib/i18n.rb +29 -4
  2. data/lib/i18n/backend/active_record/translation.rb +6 -4
  3. data/lib/i18n/backend/base.rb +1 -1
  4. data/lib/i18n/locale/fallbacks.rb +4 -4
  5. data/lib/i18n/version.rb +1 -1
  6. metadata +16 -116
  7. data/CHANGELOG.textile +0 -76
  8. data/MIT-LICENSE +0 -20
  9. data/README.textile +0 -104
  10. data/Rakefile +0 -29
  11. data/test/all.rb +0 -8
  12. data/test/api.rb +0 -18
  13. data/test/api/active_record_test.rb +0 -30
  14. data/test/api/all_features_test.rb +0 -59
  15. data/test/api/cascade_test.rb +0 -32
  16. data/test/api/chain_test.rb +0 -27
  17. data/test/api/fallbacks_test.rb +0 -34
  18. data/test/api/fast_test.rb +0 -32
  19. data/test/api/pluralization_test.rb +0 -34
  20. data/test/api/simple_test.rb +0 -23
  21. data/test/api/tests/basics.rb +0 -15
  22. data/test/api/tests/defaults.rb +0 -40
  23. data/test/api/tests/interpolation.rb +0 -92
  24. data/test/api/tests/link.rb +0 -56
  25. data/test/api/tests/localization/date.rb +0 -96
  26. data/test/api/tests/localization/date_time.rb +0 -93
  27. data/test/api/tests/localization/procs.rb +0 -60
  28. data/test/api/tests/localization/time.rb +0 -88
  29. data/test/api/tests/lookup.rb +0 -62
  30. data/test/api/tests/pluralization.rb +0 -35
  31. data/test/api/tests/procs.rb +0 -55
  32. data/test/backend/active_record/missing_test.rb +0 -51
  33. data/test/backend/active_record_test.rb +0 -57
  34. data/test/backend/cache_test.rb +0 -71
  35. data/test/backend/cascade_test.rb +0 -73
  36. data/test/backend/chain_test.rb +0 -63
  37. data/test/backend/cldr_test.rb +0 -151
  38. data/test/backend/exceptions_test.rb +0 -25
  39. data/test/backend/fallbacks_test.rb +0 -107
  40. data/test/backend/fast_test.rb +0 -50
  41. data/test/backend/helpers_test.rb +0 -27
  42. data/test/backend/interpolation_compiler_test.rb +0 -108
  43. data/test/backend/metadata_test.rb +0 -66
  44. data/test/backend/pluralization_test.rb +0 -47
  45. data/test/backend/simple_test.rb +0 -77
  46. data/test/core_ext/string/interpolate_test.rb +0 -99
  47. data/test/gettext/api_test.rb +0 -207
  48. data/test/gettext/backend_test.rb +0 -91
  49. data/test/i18n_exceptions_test.rb +0 -97
  50. data/test/i18n_load_path_test.rb +0 -23
  51. data/test/i18n_test.rb +0 -207
  52. data/test/locale/fallbacks_test.rb +0 -126
  53. data/test/locale/tag/rfc4646_test.rb +0 -143
  54. data/test/locale/tag/simple_test.rb +0 -33
  55. data/test/test_data/locales/cldr/de/calendars.yml +0 -152
  56. data/test/test_data/locales/cldr/de/currencies.yml +0 -8
  57. data/test/test_data/locales/cldr/de/numbers.yml +0 -31
  58. data/test/test_data/locales/de.po +0 -72
  59. data/test/test_data/locales/en.rb +0 -3
  60. data/test/test_data/locales/en.yml +0 -3
  61. data/test/test_data/locales/plurals.rb +0 -113
  62. data/test/test_helper.rb +0 -116
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift File.expand_path(File.dirname(__FILE__) + '/')
3
- require 'test_helper'
4
-
5
- class I18nLoadPathTest < Test::Unit::TestCase
6
- # include Tests::Backend::Simple::Setup::Base
7
-
8
- def setup
9
- I18n.locale = :en
10
- I18n.backend = I18n::Backend::Simple.new
11
- store_translations(:en, :foo => {:bar => 'bar', :baz => 'baz'})
12
- end
13
-
14
- def test_nested_load_paths_do_not_break_locale_loading
15
- I18n.load_path = [[locales_dir + '/en.yml']]
16
- assert_equal "baz", I18n.t(:'foo.bar')
17
- end
18
-
19
- def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading
20
- I18n.load_path << Dir[locales_dir + '/*.{rb,yml}']
21
- assert_equal "baz", I18n.t(:'foo.bar')
22
- end
23
- end
data/test/i18n_test.rb DELETED
@@ -1,207 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__))); $:.uniq!
3
- require 'test_helper'
4
-
5
- class I18nTest < Test::Unit::TestCase
6
- def setup
7
- I18n.backend.store_translations :'en', {
8
- :currency => {
9
- :format => {
10
- :separator => '.',
11
- :delimiter => ',',
12
- }
13
- }
14
- }
15
- end
16
-
17
- def test_uses_simple_backend_set_by_default
18
- assert I18n.backend.is_a?(I18n::Backend::Simple)
19
- end
20
-
21
- def test_can_set_backend
22
- assert_nothing_raised { I18n.backend = self }
23
- assert_equal self, I18n.backend
24
- ensure
25
- I18n.backend = I18n::Backend::Simple.new
26
- end
27
-
28
- def test_uses_en_us_as_default_locale_by_default
29
- assert_equal :en, I18n.default_locale
30
- end
31
-
32
- def test_can_set_default_locale
33
- assert_nothing_raised { I18n.default_locale = 'de' }
34
- assert_equal :de, I18n.default_locale
35
- ensure
36
- I18n.default_locale = :en
37
- end
38
-
39
- def test_uses_default_locale_as_locale_by_default
40
- assert_equal I18n.default_locale, I18n.locale
41
- end
42
-
43
- def test_can_set_locale_to_thread_current
44
- assert_nothing_raised { I18n.locale = 'de' }
45
- assert_equal :de, I18n.locale
46
- assert_equal :de, Thread.current[:i18n_config].locale
47
- I18n.locale = :en
48
- end
49
-
50
- def test_can_set_i18n_config
51
- I18n.config = self
52
- assert_equal self, I18n.config
53
- assert_equal self, Thread.current[:i18n_config]
54
- ensure
55
- I18n.config = ::I18n::Config.new
56
- end
57
-
58
- def test_locale_is_not_shared_between_configurations
59
- a = I18n::Config.new
60
- b = I18n::Config.new
61
- a.locale = :fr
62
- b.locale = :es
63
- assert_equal :fr, a.locale
64
- assert_equal :es, b.locale
65
- assert_equal :en, I18n.locale
66
- end
67
-
68
- def test_other_options_are_shared_between_configurations
69
- a = I18n::Config.new
70
- b = I18n::Config.new
71
- a.default_locale = :fr
72
- b.default_locale = :es
73
- assert_equal :es, a.default_locale
74
- assert_equal :es, b.default_locale
75
- assert_equal :es, I18n.default_locale
76
- ensure
77
- I18n.default_locale = :en
78
- end
79
-
80
- def test_defaults_to_dot_as_separator
81
- assert_equal '.', I18n.default_separator
82
- end
83
-
84
- def test_can_set_default_separator
85
- assert_nothing_raised { I18n.default_separator = "\001" }
86
- ensure
87
- I18n.default_separator = '.' # revert it
88
- end
89
-
90
- def test_normalize_keys
91
- assert_equal [:en, :foo, :bar], I18n.normalize_keys(:en, :bar, :foo)
92
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, :'baz.buz', :'foo.bar')
93
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, 'baz.buz', 'foo.bar')
94
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, %w(baz buz), %w(foo bar))
95
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, [:baz, :buz], [:foo, :bar])
96
- end
97
-
98
- def test_normalize_keys_should_not_attempt_to_sym_on_empty_string
99
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, :'baz.buz', :'foo..bar')
100
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, :'baz.buz', :'foo......bar')
101
- end
102
-
103
- def test_uses_passed_separator_to_normalize_keys
104
- assert_equal [:en, :foo, :bar, :baz, :buz], I18n.normalize_keys(:en, :'baz|buz', :'foo|bar', '|')
105
- end
106
-
107
- def test_can_set_exception_handler
108
- assert_nothing_raised { I18n.exception_handler = :custom_exception_handler }
109
- ensure
110
- I18n.exception_handler = :default_exception_handler
111
- end
112
-
113
- with_mocha do
114
- def test_uses_custom_exception_handler
115
- I18n.exception_handler = :custom_exception_handler
116
- I18n.expects(:custom_exception_handler)
117
- I18n.translate :bogus
118
- ensure
119
- I18n.exception_handler = :default_exception_handler # revert it
120
- end
121
-
122
- def test_delegates_translate_to_backend
123
- I18n.backend.expects(:translate).with('de', :foo, {})
124
- I18n.translate :foo, :locale => 'de'
125
- end
126
-
127
- def test_delegates_localize_to_backend
128
- I18n.backend.expects(:localize).with('de', :whatever, :default, {})
129
- I18n.localize :whatever, :locale => 'de'
130
- end
131
-
132
- def test_translate_given_no_locale_uses_i18n_locale
133
- I18n.backend.expects(:translate).with(:en, :foo, {})
134
- I18n.translate :foo
135
- end
136
- end
137
-
138
- def test_translate_on_nested_symbol_keys_works
139
- assert_equal ".", I18n.t(:'currency.format.separator')
140
- end
141
-
142
- def test_translate_with_nested_string_keys_works
143
- assert_equal ".", I18n.t('currency.format.separator')
144
- end
145
-
146
- def test_translate_with_array_as_scope_works
147
- assert_equal ".", I18n.t(:separator, :scope => %w(currency format))
148
- end
149
-
150
- def test_translate_with_array_containing_dot_separated_strings_as_scope_works
151
- assert_equal ".", I18n.t(:separator, :scope => ['currency.format'])
152
- end
153
-
154
- def test_translate_with_key_array_and_dot_separated_scope_works
155
- assert_equal [".", ","], I18n.t(%w(separator delimiter), :scope => 'currency.format')
156
- end
157
-
158
- def test_translate_with_dot_separated_key_array_and_scope_works
159
- assert_equal [".", ","], I18n.t(%w(format.separator format.delimiter), :scope => 'currency')
160
- end
161
-
162
- # with_mocha do
163
- # def test_translate_with_options_using_scope_works
164
- # I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format")
165
- # I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale|
166
- # locale.t :precision
167
- # end
168
- # end
169
- # end
170
-
171
- # def test_translate_given_no_args_raises_missing_translation_data
172
- # assert_equal "translation missing: en, no key", I18n.t
173
- # end
174
-
175
- def test_translate_given_a_bogus_key_raises_missing_translation_data
176
- assert_equal "translation missing: en, bogus", I18n.t(:bogus)
177
- end
178
-
179
- def test_localize_nil_raises_argument_error
180
- assert_raise(I18n::ArgumentError) { I18n.l nil }
181
- end
182
-
183
- def test_localize_object_raises_argument_error
184
- assert_raise(I18n::ArgumentError) { I18n.l Object.new }
185
- end
186
-
187
- def test_proc_exception_handler
188
- I18n.exception_handler = Proc.new { |exception, locale, key, options|
189
- "No exception here! [Proc handler]"
190
- }
191
- assert_equal "No exception here! [Proc handler]", I18n.translate(:test_proc_handler)
192
- ensure
193
- I18n.exception_handler = :default_exception_handler
194
- end
195
-
196
- def test_class_exception_handler
197
- I18n.exception_handler = Class.new do
198
- def call(exception, locale, key, options)
199
- "No exception here! [Class handler]"
200
- end
201
- end.new
202
- assert_equal "No exception here! [Class handler]", I18n.translate(:test_class_handler)
203
- ensure
204
- I18n.exception_handler = :default_exception_handler
205
- end
206
-
207
- end
@@ -1,126 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- include I18n::Locale
6
-
7
- class I18nFallbacksDefaultsTest < Test::Unit::TestCase
8
- def teardown
9
- I18n.default_locale = :en
10
- end
11
-
12
- test "defaults reflect the I18n.default_locale if no default has been set manually" do
13
- I18n.default_locale = :'en-US'
14
- fallbacks = Fallbacks.new
15
- assert_equal [:'en-US', :en], fallbacks.defaults
16
- end
17
-
18
- test "defaults reflect a manually passed default locale if any" do
19
- fallbacks = Fallbacks.new(:'fi-FI')
20
- assert_equal [:'fi-FI', :fi], fallbacks.defaults
21
- I18n.default_locale = :'de-DE'
22
- assert_equal [:'fi-FI', :fi], fallbacks.defaults
23
- end
24
-
25
- test "defaults allows to set multiple defaults" do
26
- fallbacks = Fallbacks.new(:'fi-FI', :'se-FI')
27
- assert_equal [:'fi-FI', :fi, :'se-FI', :se], fallbacks.defaults
28
- end
29
- end
30
-
31
- class I18nFallbacksComputationTest < Test::Unit::TestCase
32
- def setup
33
- @fallbacks = Fallbacks.new(:'en-US')
34
- end
35
-
36
- test "with no mappings defined it returns [:es, :en-US] for :es" do
37
- assert_equal [:es, :"en-US", :en], @fallbacks[:es]
38
- end
39
-
40
- test "with no mappings defined it returns [:es-ES, :es, :en-US] for :es-ES" do
41
- assert_equal [:"es-ES", :es, :"en-US", :en], @fallbacks[:"es-ES"]
42
- end
43
-
44
- test "with no mappings defined it returns [:es-MX, :es, :en-US] for :es-MX" do
45
- assert_equal [:"es-MX", :es, :"en-US", :en], @fallbacks[:"es-MX"]
46
- end
47
-
48
- test "with no mappings defined it returns [:es-Latn-ES, :es-Latn, :es, :en-US] for :es-Latn-ES" do
49
- assert_equal [:"es-Latn-ES", :"es-Latn", :es, :"en-US", :en], @fallbacks[:'es-Latn-ES']
50
- end
51
-
52
- test "with no mappings defined it returns [:en, :en-US] for :en" do
53
- assert_equal [:en, :"en-US"], @fallbacks[:en]
54
- end
55
-
56
- test "with no mappings defined it returns [:en-US, :en] for :en-US (special case: locale == default)" do
57
- assert_equal [:"en-US", :en], @fallbacks[:"en-US"]
58
- end
59
-
60
- # Most people who speak Catalan also live in Spain, so it is safe to assume
61
- # that they also speak Spanish as spoken in Spain.
62
- test "with a Catalan mapping defined it returns [:ca, :es-ES, :es, :en-US] for :ca" do
63
- @fallbacks.map(:ca => :"es-ES")
64
- assert_equal [:ca, :"es-ES", :es, :"en-US", :en], @fallbacks[:ca]
65
- end
66
-
67
- test "with a Catalan mapping defined it returns [:ca-ES, :ca, :es-ES, :es, :en-US] for :ca-ES" do
68
- @fallbacks.map(:ca => :"es-ES")
69
- assert_equal [:"ca-ES", :ca, :"es-ES", :es, :"en-US", :en], @fallbacks[:"ca-ES"]
70
- end
71
-
72
- # People who speak Arabic as spoken in Palestine often times also speak
73
- # Hebrew as spoken in Israel. However it is in no way safe to assume that
74
- # everybody who speaks Arabic also speaks Hebrew.
75
-
76
- test "with a Hebrew mapping defined it returns [:ar, :en-US] for :ar" do
77
- @fallbacks.map(:"ar-PS" => :"he-IL")
78
- assert_equal [:ar, :"en-US", :en], @fallbacks[:ar]
79
- end
80
-
81
- test "with a Hebrew mapping defined it returns [:ar-EG, :ar, :en-US] for :ar-EG" do
82
- @fallbacks.map(:"ar-PS" => :"he-IL")
83
- assert_equal [:"ar-EG", :ar, :"en-US", :en], @fallbacks[:"ar-EG"]
84
- end
85
-
86
- test "with a Hebrew mapping defined it returns [:ar-PS, :ar, :he-IL, :he, :en-US] for :ar-PS" do
87
- @fallbacks.map(:"ar-PS" => :"he-IL")
88
- assert_equal [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en], @fallbacks[:"ar-PS"]
89
- end
90
-
91
- # Sami people live in several scandinavian countries. In Finnland many people
92
- # know Swedish and Finnish. Thus, it can be assumed that Sami living in
93
- # Finnland also speak Swedish and Finnish.
94
-
95
- test "with a Sami mapping defined it returns [:sms-FI, :sms, :se-FI, :se, :fi-FI, :fi, :en-US] for :sms-FI" do
96
- @fallbacks.map(:sms => [:"se-FI", :"fi-FI"])
97
- assert_equal [:"sms-FI", :sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en], @fallbacks[:"sms-FI"]
98
- end
99
-
100
- # Austrian people understand German as spoken in Germany
101
-
102
- test "with a German mapping defined it returns [:de, :en-US] for de" do
103
- @fallbacks.map(:"de-AT" => :"de-DE")
104
- assert_equal [:de, :"en-US", :en], @fallbacks[:"de"]
105
- end
106
-
107
- test "with a German mapping defined it returns [:de-DE, :de, :en-US] for de-DE" do
108
- @fallbacks.map(:"de-AT" => :"de-DE")
109
- assert_equal [:"de-DE", :de, :"en-US", :en], @fallbacks[:"de-DE"]
110
- end
111
-
112
- test "with a German mapping defined it returns [:de-AT, :de, :de-DE, :en-US] for de-AT" do
113
- @fallbacks.map(:"de-AT" => :"de-DE")
114
- assert_equal [:"de-AT", :de, :"de-DE", :"en-US", :en], @fallbacks[:"de-AT"]
115
- end
116
-
117
- # Mapping :de => :en, :he => :en
118
-
119
- test "with a mapping :de => :en, :he => :en defined it returns [:de, :en] for :de" do
120
- assert_equal [:de, :"en-US", :en], @fallbacks[:de]
121
- end
122
-
123
- test "with a mapping :de => :en, :he => :en defined it [:he, :en] for :de" do
124
- assert_equal [:he, :"en-US", :en], @fallbacks[:he]
125
- end
126
- end
@@ -1,143 +0,0 @@
1
- # encoding: utf-8
2
- $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../')); $:.uniq!
3
- require 'test_helper'
4
-
5
- class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase
6
- include I18n::Locale
7
-
8
- test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do
9
- assert_equal ['de', nil, nil, nil, nil, nil, nil], Tag::Rfc4646::Parser.match('de')
10
- end
11
-
12
- test "Rfc4646::Parser given a valid tag 'de-DE' returns an array of subtags" do
13
- assert_equal ['de', nil, 'DE', nil, nil, nil, nil], Tag::Rfc4646::Parser.match('de-DE')
14
- end
15
-
16
- test "Rfc4646::Parser given a valid lowercase tag 'de-latn-de-variant-x-phonebk' returns an array of subtags" do
17
- assert_equal ['de', 'latn', 'de', 'variant', nil, 'x-phonebk', nil], Tag::Rfc4646::Parser.match('de-latn-de-variant-x-phonebk')
18
- end
19
-
20
- test "Rfc4646::Parser given a valid uppercase tag 'DE-LATN-DE-VARIANT-X-PHONEBK' returns an array of subtags" do
21
- assert_equal ['DE', 'LATN', 'DE', 'VARIANT', nil, 'X-PHONEBK', nil], Tag::Rfc4646::Parser.match('DE-LATN-DE-VARIANT-X-PHONEBK')
22
- end
23
-
24
- test "Rfc4646::Parser given an invalid tag 'a-DE' it returns false" do
25
- assert_equal false, Tag::Rfc4646::Parser.match('a-DE')
26
- end
27
-
28
- test "Rfc4646::Parser given an invalid tag 'de-419-DE' it returns false" do
29
- assert_equal false, Tag::Rfc4646::Parser.match('de-419-DE')
30
- end
31
- end
32
-
33
- # Tag for the locale 'de-Latn-DE-Variant-a-ext-x-phonebk-i-klingon'
34
-
35
- class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
36
- include I18n::Locale
37
-
38
- def setup
39
- subtags = %w(de Latn DE variant a-ext x-phonebk i-klingon)
40
- @tag = Tag::Rfc4646.new *subtags
41
- end
42
-
43
- test "returns 'de' as the language subtag in lowercase" do
44
- assert_equal 'de', @tag.language
45
- end
46
-
47
- test "returns 'Latn' as the script subtag in titlecase" do
48
- assert_equal 'Latn', @tag.script
49
- end
50
-
51
- test "returns 'DE' as the region subtag in uppercase" do
52
- assert_equal 'DE', @tag.region
53
- end
54
-
55
- test "returns 'variant' as the variant subtag in lowercase" do
56
- assert_equal 'variant', @tag.variant
57
- end
58
-
59
- test "returns 'a-ext' as the extension subtag" do
60
- assert_equal 'a-ext', @tag.extension
61
- end
62
-
63
- test "returns 'x-phonebk' as the privateuse subtag" do
64
- assert_equal 'x-phonebk', @tag.privateuse
65
- end
66
-
67
- test "returns 'i-klingon' as the grandfathered subtag" do
68
- assert_equal 'i-klingon', @tag.grandfathered
69
- end
70
-
71
- test "returns a formatted tag string from #to_s" do
72
- assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon', @tag.to_s
73
- end
74
-
75
- test "returns an array containing the formatted subtags from #to_a" do
76
- assert_equal %w(de Latn DE variant a-ext x-phonebk i-klingon), @tag.to_a
77
- end
78
- end
79
-
80
- # Tag inheritance
81
-
82
- class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
83
- test "#parent returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
84
- tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
85
- assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s
86
- end
87
-
88
- test "#parent returns 'de-Latn-DE-variant-a-ext' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk'" do
89
- tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk)
90
- assert_equal 'de-Latn-DE-variant-a-ext', tag.parent.to_s
91
- end
92
-
93
- test "#parent returns 'de-Latn-DE-variant' as the parent of 'de-Latn-DE-variant-a-ext'" do
94
- tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext)
95
- assert_equal 'de-Latn-DE-variant', tag.parent.to_s
96
- end
97
-
98
- test "#parent returns 'de-Latn-DE' as the parent of 'de-Latn-DE-variant'" do
99
- tag = Tag::Rfc4646.new *%w(de Latn DE variant)
100
- assert_equal 'de-Latn-DE', tag.parent.to_s
101
- end
102
-
103
- test "#parent returns 'de-Latn' as the parent of 'de-Latn-DE'" do
104
- tag = Tag::Rfc4646.new *%w(de Latn DE)
105
- assert_equal 'de-Latn', tag.parent.to_s
106
- end
107
-
108
- test "#parent returns 'de' as the parent of 'de-Latn'" do
109
- tag = Tag::Rfc4646.new *%w(de Latn)
110
- assert_equal 'de', tag.parent.to_s
111
- end
112
-
113
- # TODO RFC4647 says: "If no language tag matches the request, the "default" value is returned."
114
- # where should we set the default language?
115
- # test "#parent returns '' as the parent of 'de'" do
116
- # tag = Tag::Rfc4646.new *%w(de)
117
- # assert_equal '', tag.parent.to_s
118
- # end
119
-
120
- test "#parent returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
121
- parents = %w(de-Latn-DE-variant-a-ext-x-phonebk-i-klingon
122
- de-Latn-DE-variant-a-ext-x-phonebk
123
- de-Latn-DE-variant-a-ext
124
- de-Latn-DE-variant
125
- de-Latn-DE
126
- de-Latn
127
- de)
128
- tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
129
- assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
130
- end
131
-
132
- test "returns an array of 5 parents for 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
133
- parents = %w(de-Latn-DE-variant-a-ext-x-phonebk-i-klingon
134
- de-Latn-DE-variant-a-ext-x-phonebk
135
- de-Latn-DE-variant-a-ext
136
- de-Latn-DE-variant
137
- de-Latn-DE
138
- de-Latn
139
- de)
140
- tag = Tag::Rfc4646.new *%w(de Latn DE variant a-ext x-phonebk i-klingon)
141
- assert_equal parents, tag.self_and_parents.map{|tag| tag.to_s}
142
- end
143
- end