svenfuchs-i18n 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/i18n.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "i18n"
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
  s.date = "2008-10-26"
5
5
  s.summary = "Internationalization support for Ruby"
6
6
  s.email = "rails-i18n@googlegroups.com"
@@ -20,8 +20,8 @@ Gem::Specification.new do |s|
20
20
  'test/all.rb',
21
21
  'test/i18n_exceptions_test.rb',
22
22
  'test/i18n_test.rb',
23
- 'test/locale/en-US.rb',
24
- 'test/locale/en-US.yml',
23
+ 'test/locale/en.rb',
24
+ 'test/locale/en.yml',
25
25
  'test/simple_backend_test.rb'
26
26
  ]
27
- end
27
+ end
data/lib/i18n.rb CHANGED
@@ -11,7 +11,7 @@ require 'i18n/exceptions'
11
11
  module I18n
12
12
  @@backend = nil
13
13
  @@load_path = nil
14
- @@default_locale = :'en-US'
14
+ @@default_locale = :'en'
15
15
  @@exception_handler = :default_exception_handler
16
16
 
17
17
  class << self
@@ -25,7 +25,7 @@ module I18n
25
25
  @@backend = backend
26
26
  end
27
27
 
28
- # Returns the current default locale. Defaults to 'en-US'
28
+ # Returns the current default locale. Defaults to :'en'
29
29
  def default_locale
30
30
  @@default_locale
31
31
  end
@@ -57,7 +57,7 @@ module I18n
57
57
  # files which are either named *.rb and contain plain Ruby Hashes or are
58
58
  # named *.yml and contain YAML data. So for the SimpleBackend clients may
59
59
  # register translation files like this:
60
- # I18n.load_path << 'path/to/locale/en-US.yml'
60
+ # I18n.load_path << 'path/to/locale/en.yml'
61
61
  def load_path
62
62
  @@load_path ||= []
63
63
  end
@@ -23,7 +23,7 @@ class I18nExceptionsTest < Test::Unit::TestCase
23
23
  force_missing_translation_data
24
24
  rescue I18n::ArgumentError => e
25
25
  options = {:scope => :bar}
26
- assert_equal 'de-DE', e.locale
26
+ assert_equal 'de', e.locale
27
27
  assert_equal :foo, e.key
28
28
  assert_equal options, e.options
29
29
  end
@@ -31,7 +31,7 @@ class I18nExceptionsTest < Test::Unit::TestCase
31
31
  def test_missing_translation_data_message
32
32
  force_missing_translation_data
33
33
  rescue I18n::ArgumentError => e
34
- assert_equal 'translation missing: de-DE, bar, foo', e.message
34
+ assert_equal 'translation missing: de, bar, foo', e.message
35
35
  end
36
36
 
37
37
  def test_invalid_pluralization_data_stores_entry_and_count
@@ -79,22 +79,22 @@ class I18nExceptionsTest < Test::Unit::TestCase
79
79
  end
80
80
 
81
81
  def force_missing_translation_data
82
- I18n.backend.store_translations 'de-DE', :bar => nil
83
- I18n.backend.translate 'de-DE', :foo, :scope => :bar
82
+ I18n.backend.store_translations 'de', :bar => nil
83
+ I18n.backend.translate 'de', :foo, :scope => :bar
84
84
  end
85
85
 
86
86
  def force_invalid_pluralization_data
87
- I18n.backend.store_translations 'de-DE', :foo => [:bar]
88
- I18n.backend.translate 'de-DE', :foo, :count => 1
87
+ I18n.backend.store_translations 'de', :foo => [:bar]
88
+ I18n.backend.translate 'de', :foo, :count => 1
89
89
  end
90
90
 
91
91
  def force_missing_interpolation_argument
92
- I18n.backend.store_translations 'de-DE', :foo => "{{bar}}"
93
- I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
92
+ I18n.backend.store_translations 'de', :foo => "{{bar}}"
93
+ I18n.backend.translate 'de', :foo, :baz => 'baz'
94
94
  end
95
95
 
96
96
  def force_reserved_interpolation_key
97
- I18n.backend.store_translations 'de-DE', :foo => "{{scope}}"
98
- I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
97
+ I18n.backend.store_translations 'de', :foo => "{{scope}}"
98
+ I18n.backend.translate 'de', :foo, :baz => 'baz'
99
99
  end
100
100
  end
data/test/i18n_test.rb CHANGED
@@ -8,7 +8,7 @@ require 'active_support'
8
8
 
9
9
  class I18nTest < Test::Unit::TestCase
10
10
  def setup
11
- I18n.backend.store_translations :'en-US', {
11
+ I18n.backend.store_translations :'en', {
12
12
  :currency => {
13
13
  :format => {
14
14
  :separator => '.',
@@ -29,13 +29,13 @@ class I18nTest < Test::Unit::TestCase
29
29
  end
30
30
 
31
31
  def test_uses_en_us_as_default_locale_by_default
32
- assert_equal 'en-US', I18n.default_locale
32
+ assert_equal 'en', I18n.default_locale
33
33
  end
34
34
 
35
35
  def test_can_set_default_locale
36
- assert_nothing_raised{ I18n.default_locale = 'de-DE' }
37
- assert_equal 'de-DE', I18n.default_locale
38
- I18n.default_locale = 'en-US'
36
+ assert_nothing_raised{ I18n.default_locale = 'de' }
37
+ assert_equal 'de', I18n.default_locale
38
+ I18n.default_locale = 'en'
39
39
  end
40
40
 
41
41
  def test_uses_default_locale_as_locale_by_default
@@ -43,10 +43,10 @@ class I18nTest < Test::Unit::TestCase
43
43
  end
44
44
 
45
45
  def test_can_set_locale_to_thread_current
46
- assert_nothing_raised{ I18n.locale = 'de-DE' }
47
- assert_equal 'de-DE', I18n.locale
48
- assert_equal 'de-DE', Thread.current[:locale]
49
- I18n.locale = 'en-US'
46
+ assert_nothing_raised{ I18n.locale = 'de' }
47
+ assert_equal 'de', I18n.locale
48
+ assert_equal 'de', Thread.current[:locale]
49
+ I18n.locale = 'en'
50
50
  end
51
51
 
52
52
  def test_can_set_exception_handler
@@ -62,17 +62,17 @@ class I18nTest < Test::Unit::TestCase
62
62
  end
63
63
 
64
64
  def test_delegates_translate_to_backend
65
- I18n.backend.expects(:translate).with 'de-DE', :foo, {}
66
- I18n.translate :foo, :locale => 'de-DE'
65
+ I18n.backend.expects(:translate).with 'de', :foo, {}
66
+ I18n.translate :foo, :locale => 'de'
67
67
  end
68
68
 
69
69
  def test_delegates_localize_to_backend
70
- I18n.backend.expects(:localize).with 'de-DE', :whatever, :default
71
- I18n.localize :whatever, :locale => 'de-DE'
70
+ I18n.backend.expects(:localize).with 'de', :whatever, :default
71
+ I18n.localize :whatever, :locale => 'de'
72
72
  end
73
73
 
74
74
  def test_translate_given_no_locale_uses_i18n_locale
75
- I18n.backend.expects(:translate).with 'en-US', :foo, {}
75
+ I18n.backend.expects(:translate).with 'en', :foo, {}
76
76
  I18n.translate :foo
77
77
  end
78
78
 
@@ -101,18 +101,18 @@ class I18nTest < Test::Unit::TestCase
101
101
  end
102
102
 
103
103
  def test_translate_with_options_using_scope_works
104
- I18n.backend.expects(:translate).with('de-DE', :precision, :scope => :"currency.format")
105
- I18n.with_options :locale => 'de-DE', :scope => :'currency.format' do |locale|
104
+ I18n.backend.expects(:translate).with('de', :precision, :scope => :"currency.format")
105
+ I18n.with_options :locale => 'de', :scope => :'currency.format' do |locale|
106
106
  locale.t :precision
107
107
  end
108
108
  end
109
109
 
110
110
  # def test_translate_given_no_args_raises_missing_translation_data
111
- # assert_equal "translation missing: en-US, no key", I18n.t
111
+ # assert_equal "translation missing: en, no key", I18n.t
112
112
  # end
113
113
 
114
114
  def test_translate_given_a_bogus_key_raises_missing_translation_data
115
- assert_equal "translation missing: en-US, bogus", I18n.t(:bogus)
115
+ assert_equal "translation missing: en, bogus", I18n.t(:bogus)
116
116
  end
117
117
 
118
118
  def test_localize_nil_raises_argument_error
data/test/locale/en.rb ADDED
@@ -0,0 +1 @@
1
+ {:'en-Ruby' => {:foo => {:bar => "baz"}}}
@@ -0,0 +1,3 @@
1
+ en-Yaml:
2
+ foo:
3
+ bar: baz
@@ -12,7 +12,7 @@ module I18nSimpleBackendTestSetup
12
12
  def setup_backend
13
13
  # backend_reset_translations!
14
14
  @backend = I18n::Backend::Simple.new
15
- @backend.store_translations 'en-US', :foo => {:bar => 'bar', :baz => 'baz'}
15
+ @backend.store_translations 'en', :foo => {:bar => 'bar', :baz => 'baz'}
16
16
  @locale_dir = File.dirname(__FILE__) + '/locale'
17
17
  end
18
18
  alias :setup :setup_backend
@@ -27,7 +27,7 @@ module I18nSimpleBackendTestSetup
27
27
  end
28
28
 
29
29
  def add_datetime_translations
30
- @backend.store_translations :'de-DE', {
30
+ @backend.store_translations :'de', {
31
31
  :date => {
32
32
  :formats => {
33
33
  :default => "%d.%m.%Y",
@@ -102,25 +102,25 @@ class I18nSimpleBackendTranslationsTest < Test::Unit::TestCase
102
102
  include I18nSimpleBackendTestSetup
103
103
 
104
104
  def test_store_translations_adds_translations # no, really :-)
105
- @backend.store_translations :'en-US', :foo => 'bar'
106
- assert_equal Hash[:'en-US', {:foo => 'bar'}], backend_get_translations
105
+ @backend.store_translations :'en', :foo => 'bar'
106
+ assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
107
107
  end
108
108
 
109
109
  def test_store_translations_deep_merges_translations
110
- @backend.store_translations :'en-US', :foo => {:bar => 'bar'}
111
- @backend.store_translations :'en-US', :foo => {:baz => 'baz'}
112
- assert_equal Hash[:'en-US', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
110
+ @backend.store_translations :'en', :foo => {:bar => 'bar'}
111
+ @backend.store_translations :'en', :foo => {:baz => 'baz'}
112
+ assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
113
113
  end
114
114
 
115
115
  def test_store_translations_forces_locale_to_sym
116
- @backend.store_translations 'en-US', :foo => 'bar'
117
- assert_equal Hash[:'en-US', {:foo => 'bar'}], backend_get_translations
116
+ @backend.store_translations 'en', :foo => 'bar'
117
+ assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
118
118
  end
119
119
 
120
120
  def test_store_translations_converts_keys_to_symbols
121
121
  # backend_reset_translations!
122
- @backend.store_translations 'en-US', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
123
- assert_equal Hash[:'en-US', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
122
+ @backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
123
+ assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
124
124
  end
125
125
  end
126
126
 
@@ -128,45 +128,45 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase
128
128
  include I18nSimpleBackendTestSetup
129
129
 
130
130
  def test_translate_calls_lookup_with_locale_given
131
- @backend.expects(:lookup).with('de-DE', :bar, [:foo]).returns 'bar'
132
- @backend.translate 'de-DE', :bar, :scope => [:foo]
131
+ @backend.expects(:lookup).with('de', :bar, [:foo]).returns 'bar'
132
+ @backend.translate 'de', :bar, :scope => [:foo]
133
133
  end
134
134
 
135
135
  def test_given_no_keys_it_returns_the_default
136
- assert_equal 'default', @backend.translate('en-US', nil, :default => 'default')
136
+ assert_equal 'default', @backend.translate('en', nil, :default => 'default')
137
137
  end
138
138
 
139
139
  def test_translate_given_a_symbol_as_a_default_translates_the_symbol
140
- assert_equal 'bar', @backend.translate('en-US', nil, :scope => [:foo], :default => :bar)
140
+ assert_equal 'bar', @backend.translate('en', nil, :scope => [:foo], :default => :bar)
141
141
  end
142
142
 
143
143
  def test_translate_given_an_array_as_default_uses_the_first_match
144
- assert_equal 'bar', @backend.translate('en-US', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
144
+ assert_equal 'bar', @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
145
145
  end
146
146
 
147
147
  def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data
148
148
  assert_raises I18n::MissingTranslationData do
149
- @backend.translate('en-US', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
149
+ @backend.translate('en', :does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
150
150
  end
151
151
  end
152
152
 
153
153
  def test_translate_an_array_of_keys_translates_all_of_them
154
- assert_equal %w(bar baz), @backend.translate('en-US', [:bar, :baz], :scope => [:foo])
154
+ assert_equal %w(bar baz), @backend.translate('en', [:bar, :baz], :scope => [:foo])
155
155
  end
156
156
 
157
157
  def test_translate_calls_pluralize
158
- @backend.expects(:pluralize).with 'en-US', 'bar', 1
159
- @backend.translate 'en-US', :bar, :scope => [:foo], :count => 1
158
+ @backend.expects(:pluralize).with 'en', 'bar', 1
159
+ @backend.translate 'en', :bar, :scope => [:foo], :count => 1
160
160
  end
161
161
 
162
162
  def test_translate_calls_interpolate
163
- @backend.expects(:interpolate).with 'en-US', 'bar', {}
164
- @backend.translate 'en-US', :bar, :scope => [:foo]
163
+ @backend.expects(:interpolate).with 'en', 'bar', {}
164
+ @backend.translate 'en', :bar, :scope => [:foo]
165
165
  end
166
166
 
167
167
  def test_translate_calls_interpolate_including_count_as_a_value
168
- @backend.expects(:interpolate).with 'en-US', 'bar', {:count => 1}
169
- @backend.translate 'en-US', :bar, :scope => [:foo], :count => 1
168
+ @backend.expects(:interpolate).with 'en', 'bar', {:count => 1}
169
+ @backend.translate 'en', :bar, :scope => [:foo], :count => 1
170
170
  end
171
171
 
172
172
  def test_translate_given_nil_as_a_locale_raises_an_argument_error
@@ -174,7 +174,7 @@ class I18nSimpleBackendTranslateTest < Test::Unit::TestCase
174
174
  end
175
175
 
176
176
  def test_translate_with_a_bogus_key_and_no_default_raises_missing_translation_data
177
- assert_raises(I18n::MissingTranslationData){ @backend.translate 'de-DE', :bogus }
177
+ assert_raises(I18n::MissingTranslationData){ @backend.translate 'de', :bogus }
178
178
  end
179
179
  end
180
180
 
@@ -183,11 +183,11 @@ class I18nSimpleBackendLookupTest < Test::Unit::TestCase
183
183
 
184
184
  # useful because this way we can use the backend with no key for interpolation/pluralization
185
185
  def test_lookup_given_nil_as_a_key_returns_nil
186
- assert_nil @backend.send(:lookup, 'en-US', nil)
186
+ assert_nil @backend.send(:lookup, 'en', nil)
187
187
  end
188
188
 
189
189
  def test_lookup_given_nested_keys_looks_up_a_nested_hash_value
190
- assert_equal 'bar', @backend.send(:lookup, 'en-US', :bar, [:foo])
190
+ assert_equal 'bar', @backend.send(:lookup, 'en', :bar, [:foo])
191
191
  end
192
192
  end
193
193
 
@@ -274,47 +274,47 @@ class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase
274
274
  end
275
275
 
276
276
  def test_translate_given_the_short_format_it_uses_it
277
- assert_equal '01. Jan', @backend.localize('de-DE', @date, :short)
277
+ assert_equal '01. Jan', @backend.localize('de', @date, :short)
278
278
  end
279
279
 
280
280
  def test_translate_given_the_long_format_it_uses_it
281
- assert_equal '01. Januar 2008', @backend.localize('de-DE', @date, :long)
281
+ assert_equal '01. Januar 2008', @backend.localize('de', @date, :long)
282
282
  end
283
283
 
284
284
  def test_translate_given_the_default_format_it_uses_it
285
- assert_equal '01.01.2008', @backend.localize('de-DE', @date, :default)
285
+ assert_equal '01.01.2008', @backend.localize('de', @date, :default)
286
286
  end
287
287
 
288
288
  def test_translate_given_a_day_name_format_it_returns_a_day_name
289
- assert_equal 'Dienstag', @backend.localize('de-DE', @date, '%A')
289
+ assert_equal 'Dienstag', @backend.localize('de', @date, '%A')
290
290
  end
291
291
 
292
292
  def test_translate_given_an_abbr_day_name_format_it_returns_an_abbrevated_day_name
293
- assert_equal 'Di', @backend.localize('de-DE', @date, '%a')
293
+ assert_equal 'Di', @backend.localize('de', @date, '%a')
294
294
  end
295
295
 
296
296
  def test_translate_given_a_month_name_format_it_returns_a_month_name
297
- assert_equal 'Januar', @backend.localize('de-DE', @date, '%B')
297
+ assert_equal 'Januar', @backend.localize('de', @date, '%B')
298
298
  end
299
299
 
300
300
  def test_translate_given_an_abbr_month_name_format_it_returns_an_abbrevated_month_name
301
- assert_equal 'Jan', @backend.localize('de-DE', @date, '%b')
301
+ assert_equal 'Jan', @backend.localize('de', @date, '%b')
302
302
  end
303
303
 
304
304
  def test_translate_given_no_format_it_does_not_fail
305
- assert_nothing_raised{ @backend.localize 'de-DE', @date }
305
+ assert_nothing_raised{ @backend.localize 'de', @date }
306
306
  end
307
307
 
308
308
  def test_translate_given_an_unknown_format_it_does_not_fail
309
- assert_nothing_raised{ @backend.localize 'de-DE', @date, '%x' }
309
+ assert_nothing_raised{ @backend.localize 'de', @date, '%x' }
310
310
  end
311
311
 
312
312
  def test_localize_nil_raises_argument_error
313
- assert_raises(I18n::ArgumentError) { @backend.localize 'de-DE', nil }
313
+ assert_raises(I18n::ArgumentError) { @backend.localize 'de', nil }
314
314
  end
315
315
 
316
316
  def test_localize_object_raises_argument_error
317
- assert_raises(I18n::ArgumentError) { @backend.localize 'de-DE', Object.new }
317
+ assert_raises(I18n::ArgumentError) { @backend.localize 'de', Object.new }
318
318
  end
319
319
  end
320
320
 
@@ -329,44 +329,44 @@ class I18nSimpleBackendLocalizeDateTimeTest < Test::Unit::TestCase
329
329
  end
330
330
 
331
331
  def test_translate_given_the_short_format_it_uses_it
332
- assert_equal '01. Jan 06:00', @backend.localize('de-DE', @morning, :short)
332
+ assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short)
333
333
  end
334
334
 
335
335
  def test_translate_given_the_long_format_it_uses_it
336
- assert_equal '01. Januar 2008 06:00', @backend.localize('de-DE', @morning, :long)
336
+ assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long)
337
337
  end
338
338
 
339
339
  def test_translate_given_the_default_format_it_uses_it
340
- assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de-DE', @morning, :default)
340
+ assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default)
341
341
  end
342
342
 
343
343
  def test_translate_given_a_day_name_format_it_returns_the_correct_day_name
344
- assert_equal 'Dienstag', @backend.localize('de-DE', @morning, '%A')
344
+ assert_equal 'Dienstag', @backend.localize('de', @morning, '%A')
345
345
  end
346
346
 
347
347
  def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
348
- assert_equal 'Di', @backend.localize('de-DE', @morning, '%a')
348
+ assert_equal 'Di', @backend.localize('de', @morning, '%a')
349
349
  end
350
350
 
351
351
  def test_translate_given_a_month_name_format_it_returns_the_correct_month_name
352
- assert_equal 'Januar', @backend.localize('de-DE', @morning, '%B')
352
+ assert_equal 'Januar', @backend.localize('de', @morning, '%B')
353
353
  end
354
354
 
355
355
  def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
356
- assert_equal 'Jan', @backend.localize('de-DE', @morning, '%b')
356
+ assert_equal 'Jan', @backend.localize('de', @morning, '%b')
357
357
  end
358
358
 
359
359
  def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
360
- assert_equal 'am', @backend.localize('de-DE', @morning, '%p')
361
- assert_equal 'pm', @backend.localize('de-DE', @evening, '%p')
360
+ assert_equal 'am', @backend.localize('de', @morning, '%p')
361
+ assert_equal 'pm', @backend.localize('de', @evening, '%p')
362
362
  end
363
363
 
364
364
  def test_translate_given_no_format_it_does_not_fail
365
- assert_nothing_raised{ @backend.localize 'de-DE', @morning }
365
+ assert_nothing_raised{ @backend.localize 'de', @morning }
366
366
  end
367
367
 
368
368
  def test_translate_given_an_unknown_format_it_does_not_fail
369
- assert_nothing_raised{ @backend.localize 'de-DE', @morning, '%x' }
369
+ assert_nothing_raised{ @backend.localize 'de', @morning, '%x' }
370
370
  end
371
371
  end
372
372
 
@@ -386,45 +386,45 @@ class I18nSimpleBackendLocalizeTimeTest < Test::Unit::TestCase
386
386
  end
387
387
 
388
388
  def test_translate_given_the_short_format_it_uses_it
389
- assert_equal '01. Jan 06:00', @backend.localize('de-DE', @morning, :short)
389
+ assert_equal '01. Jan 06:00', @backend.localize('de', @morning, :short)
390
390
  end
391
391
 
392
392
  def test_translate_given_the_long_format_it_uses_it
393
- assert_equal '01. Januar 2008 06:00', @backend.localize('de-DE', @morning, :long)
393
+ assert_equal '01. Januar 2008 06:00', @backend.localize('de', @morning, :long)
394
394
  end
395
395
 
396
396
  # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
397
397
  # def test_translate_given_the_default_format_it_uses_it
398
- # assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de-DE', @morning, :default)
398
+ # assert_equal 'Di, 01. Jan 2008 06:00:00 +0000', @backend.localize('de', @morning, :default)
399
399
  # end
400
400
 
401
401
  def test_translate_given_a_day_name_format_it_returns_the_correct_day_name
402
- assert_equal 'Dienstag', @backend.localize('de-DE', @morning, '%A')
402
+ assert_equal 'Dienstag', @backend.localize('de', @morning, '%A')
403
403
  end
404
404
 
405
405
  def test_translate_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
406
- assert_equal 'Di', @backend.localize('de-DE', @morning, '%a')
406
+ assert_equal 'Di', @backend.localize('de', @morning, '%a')
407
407
  end
408
408
 
409
409
  def test_translate_given_a_month_name_format_it_returns_the_correct_month_name
410
- assert_equal 'Januar', @backend.localize('de-DE', @morning, '%B')
410
+ assert_equal 'Januar', @backend.localize('de', @morning, '%B')
411
411
  end
412
412
 
413
413
  def test_translate_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
414
- assert_equal 'Jan', @backend.localize('de-DE', @morning, '%b')
414
+ assert_equal 'Jan', @backend.localize('de', @morning, '%b')
415
415
  end
416
416
 
417
417
  def test_translate_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
418
- assert_equal 'am', @backend.localize('de-DE', @morning, '%p')
419
- assert_equal 'pm', @backend.localize('de-DE', @evening, '%p')
418
+ assert_equal 'am', @backend.localize('de', @morning, '%p')
419
+ assert_equal 'pm', @backend.localize('de', @evening, '%p')
420
420
  end
421
421
 
422
422
  def test_translate_given_no_format_it_does_not_fail
423
- assert_nothing_raised{ @backend.localize 'de-DE', @morning }
423
+ assert_nothing_raised{ @backend.localize 'de', @morning }
424
424
  end
425
425
 
426
426
  def test_translate_given_an_unknown_format_it_does_not_fail
427
- assert_nothing_raised{ @backend.localize 'de-DE', @morning, '%x' }
427
+ assert_nothing_raised{ @backend.localize 'de', @morning, '%x' }
428
428
  end
429
429
  end
430
430
 
@@ -444,29 +444,29 @@ class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
444
444
  include I18nSimpleBackendTestSetup
445
445
 
446
446
  def test_load_translations_with_unknown_file_type_raises_exception
447
- assert_raises(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en-US.xml" }
447
+ assert_raises(I18n::UnknownFileType) { @backend.load_translations "#{@locale_dir}/en.xml" }
448
448
  end
449
449
 
450
450
  def test_load_translations_with_ruby_file_type_does_not_raise_exception
451
- assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en-US.rb" }
451
+ assert_nothing_raised { @backend.load_translations "#{@locale_dir}/en.rb" }
452
452
  end
453
453
 
454
454
  def test_load_rb_loads_data_from_ruby_file
455
- data = @backend.send :load_rb, "#{@locale_dir}/en-US.rb"
456
- assert_equal({:'en-US-Ruby' => {:foo => {:bar => "baz"}}}, data)
455
+ data = @backend.send :load_rb, "#{@locale_dir}/en.rb"
456
+ assert_equal({:'en-Ruby' => {:foo => {:bar => "baz"}}}, data)
457
457
  end
458
458
 
459
459
  def test_load_rb_loads_data_from_yaml_file
460
- data = @backend.send :load_yml, "#{@locale_dir}/en-US.yml"
461
- assert_equal({'en-US-Yaml' => {'foo' => {'bar' => 'baz'}}}, data)
460
+ data = @backend.send :load_yml, "#{@locale_dir}/en.yml"
461
+ assert_equal({'en-Yaml' => {'foo' => {'bar' => 'baz'}}}, data)
462
462
  end
463
463
 
464
464
  def test_load_translations_loads_from_different_file_formats
465
465
  @backend = I18n::Backend::Simple.new
466
- @backend.load_translations "#{@locale_dir}/en-US.rb", "#{@locale_dir}/en-US.yml"
466
+ @backend.load_translations "#{@locale_dir}/en.rb", "#{@locale_dir}/en.yml"
467
467
  expected = {
468
- :'en-US-Ruby' => {:foo => {:bar => "baz"}},
469
- :'en-US-Yaml' => {:foo => {:bar => "baz"}}
468
+ :'en-Ruby' => {:foo => {:bar => "baz"}},
469
+ :'en-Yaml' => {:foo => {:bar => "baz"}}
470
470
  }
471
471
  assert_equal expected, backend_get_translations
472
472
  end
@@ -477,7 +477,7 @@ class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
477
477
 
478
478
  def setup
479
479
  @backend = I18n::Backend::Simple.new
480
- I18n.load_path = [File.dirname(__FILE__) + '/locale/en-US.yml']
480
+ I18n.load_path = [File.dirname(__FILE__) + '/locale/en.yml']
481
481
  assert_nil backend_get_translations
482
482
  @backend.send :init_translations
483
483
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svenfuchs-i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -62,6 +62,6 @@ test_files:
62
62
  - test/all.rb
63
63
  - test/i18n_exceptions_test.rb
64
64
  - test/i18n_test.rb
65
- - test/locale/en-US.rb
66
- - test/locale/en-US.yml
65
+ - test/locale/en.rb
66
+ - test/locale/en.yml
67
67
  - test/simple_backend_test.rb
data/test/locale/en-US.rb DELETED
@@ -1 +0,0 @@
1
- {:'en-US-Ruby' => {:foo => {:bar => "baz"}}}
@@ -1,3 +0,0 @@
1
- en-US-Yaml:
2
- foo:
3
- bar: baz