theoooo-i18n 0.2.0

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.
@@ -0,0 +1,145 @@
1
+ module Tests
2
+ module Backend
3
+ module ActiveRecord
4
+ module Setup
5
+ module Base
6
+ def setup
7
+ super
8
+ I18n.locale = nil
9
+ I18n.default_locale = :en
10
+ I18n.backend = I18n::Backend::ActiveRecord.new
11
+ backend_store_translations :en, :foo => {:bar => 'bar', :baz => 'baz'}
12
+ end
13
+
14
+ def teardown
15
+ super
16
+ Translation.destroy_all
17
+ I18n.backend = nil
18
+ end
19
+ end
20
+
21
+ module Localization
22
+ include Base
23
+
24
+ def setup
25
+ super
26
+ setup_datetime_translations
27
+ setup_datetime_lambda_translations
28
+ @old_timezone, ENV['TZ'] = ENV['TZ'], 'UTC'
29
+ end
30
+
31
+ def teardown
32
+ super
33
+ @old_timezone ? ENV['TZ'] = @old_timezone : ENV.delete('TZ')
34
+ end
35
+
36
+ def setup_datetime_translations
37
+ backend_store_translations :de, {
38
+ :date => {
39
+ :formats => {
40
+ :default => "%d.%m.%Y",
41
+ :short => "%d. %b",
42
+ :long => "%d. %B %Y",
43
+ :long_ordinalized => lambda { |date, options|
44
+ tz = " (#{options[:timezone]})" if options[:timezone]
45
+ "#{date.day}ter %B %Y#{tz}"
46
+ }
47
+ },
48
+ :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
49
+ :abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
50
+ :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
51
+ :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil),
52
+ :order => [:day, :month, :year]
53
+ },
54
+ :time => {
55
+ :formats => {
56
+ :default => "%a, %d. %b %Y %H:%M:%S %z",
57
+ :short => "%d. %b %H:%M",
58
+ :long => "%d. %B %Y %H:%M",
59
+ :long_ordinalized => lambda { |date, options|
60
+ tz = " (#{options[:timezone]})" if options[:timezone]
61
+ "#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
62
+ }
63
+ },
64
+ :am => 'am',
65
+ :pm => 'pm'
66
+ },
67
+ :datetime => {
68
+ :distance_in_words => {
69
+ :half_a_minute => 'half a minute',
70
+ :less_than_x_seconds => {
71
+ :one => 'less than 1 second',
72
+ :other => 'less than {{count}} seconds'
73
+ },
74
+ :x_seconds => {
75
+ :one => '1 second',
76
+ :other => '{{count}} seconds'
77
+ },
78
+ :less_than_x_minutes => {
79
+ :one => 'less than a minute',
80
+ :other => 'less than {{count}} minutes'
81
+ },
82
+ :x_minutes => {
83
+ :one => '1 minute',
84
+ :other => '{{count}} minutes'
85
+ },
86
+ :about_x_hours => {
87
+ :one => 'about 1 hour',
88
+ :other => 'about {{count}} hours'
89
+ },
90
+ :x_days => {
91
+ :one => '1 day',
92
+ :other => '{{count}} days'
93
+ },
94
+ :about_x_months => {
95
+ :one => 'about 1 month',
96
+ :other => 'about {{count}} months'
97
+ },
98
+ :x_months => {
99
+ :one => '1 month',
100
+ :other => '{{count}} months'
101
+ },
102
+ :about_x_years => {
103
+ :one => 'about 1 year',
104
+ :other => 'about {{count}} year'
105
+ },
106
+ :over_x_years => {
107
+ :one => 'over 1 year',
108
+ :other => 'over {{count}} years'
109
+ }
110
+ }
111
+ }
112
+ }
113
+ end
114
+
115
+ def setup_datetime_lambda_translations
116
+ backend_store_translations 'ru', {
117
+ :date => {
118
+ :'day_names' => lambda { |key, options|
119
+ (options[:format] =~ /^%A/) ?
120
+ %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
121
+ %w(воскресенье понедельник вторник среда четверг пятница суббота)
122
+ },
123
+ :'abbr_day_names' => %w(Вс Пн Вт Ср Чт Пт Сб),
124
+ :'month_names' => lambda { |key, options|
125
+ (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
126
+ %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
127
+ %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
128
+ },
129
+ :'abbr_month_names' => lambda { |key, options|
130
+ (options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
131
+ %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
132
+ %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
133
+ },
134
+ },
135
+ :time => {
136
+ :am => "утра",
137
+ :pm => "вечера"
138
+ }
139
+ }
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,3 @@
1
+ Dir[File.dirname(__FILE__) + '/*_test.rb'].each do |file|
2
+ require file
3
+ end
@@ -0,0 +1,85 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
+
4
+ class I18nSimpleBackendApiBasicsTest < Test::Unit::TestCase
5
+ include Tests::Backend::Simple::Setup::Base
6
+ include Tests::Backend::Api::Basics
7
+ end
8
+
9
+ class I18nSimpleBackendApiTranslateTest < Test::Unit::TestCase
10
+ include Tests::Backend::Simple::Setup::Base
11
+ include Tests::Backend::Api::Translation
12
+
13
+ # implementation specific tests
14
+
15
+ def test_translate_calls_lookup_with_locale_given
16
+ I18n.backend.expects(:lookup).with('de', :bar, [:foo], nil).returns 'bar'
17
+ I18n.backend.translate 'de', :bar, :scope => [:foo]
18
+ end
19
+
20
+ def test_translate_calls_pluralize
21
+ I18n.backend.expects(:pluralize).with 'en', 'bar', 1
22
+ I18n.backend.translate 'en', :bar, :scope => [:foo], :count => 1
23
+ end
24
+
25
+ def test_translate_calls_interpolate
26
+ I18n.backend.expects(:interpolate).with 'en', 'bar', {}
27
+ I18n.backend.translate 'en', :bar, :scope => [:foo]
28
+ end
29
+
30
+ def test_translate_calls_interpolate_including_count_as_a_value
31
+ I18n.backend.expects(:interpolate).with 'en', 'bar', {:count => 1}
32
+ I18n.backend.translate 'en', :bar, :scope => [:foo], :count => 1
33
+ end
34
+ end
35
+
36
+ class I18nSimpleBackendApiInterpolateTest < Test::Unit::TestCase
37
+ include Tests::Backend::Simple::Setup::Base
38
+ include Tests::Backend::Api::Interpolation
39
+
40
+ # implementation specific tests
41
+
42
+ def test_interpolate_given_nil_as_a_string_returns_nil
43
+ assert_nil I18n.backend.send(:interpolate, nil, nil, :name => 'David')
44
+ end
45
+
46
+ def test_interpolate_given_an_non_string_as_a_string_returns_nil
47
+ assert_equal [], I18n.backend.send(:interpolate, nil, [], :name => 'David')
48
+ end
49
+ end
50
+
51
+ class I18nSimpleBackendApiLambdaTest < Test::Unit::TestCase
52
+ include Tests::Backend::Simple::Setup::Base
53
+ include Tests::Backend::Api::Lambda
54
+ end
55
+
56
+ class I18nSimpleBackendApiTranslateLinkedTest < Test::Unit::TestCase
57
+ include Tests::Backend::Simple::Setup::Base
58
+ include Tests::Backend::Api::Link
59
+ end
60
+
61
+ class I18nSimpleBackendApiPluralizationTest < Test::Unit::TestCase
62
+ include Tests::Backend::Simple::Setup::Base
63
+ include Tests::Backend::Api::Pluralization
64
+ end
65
+
66
+ class I18nSimpleBackendApiLocalizeDateTest < Test::Unit::TestCase
67
+ include Tests::Backend::Simple::Setup::Localization
68
+ include Tests::Backend::Api::Localization::Date
69
+ end
70
+
71
+ class I18nSimpleBackendApiLocalizeDateTimeTest < Test::Unit::TestCase
72
+ include Tests::Backend::Simple::Setup::Localization
73
+ include Tests::Backend::Api::Localization::DateTime
74
+ end
75
+
76
+ class I18nSimpleBackendApiLocalizeTimeTest < Test::Unit::TestCase
77
+ include Tests::Backend::Simple::Setup::Localization
78
+ include Tests::Backend::Api::Localization::Time
79
+ end
80
+
81
+ class I18nSimpleBackendApiLocalizeLambdaTest < Test::Unit::TestCase
82
+ include Tests::Backend::Simple::Setup::Localization
83
+ include Tests::Backend::Api::Localization::Lambda
84
+ end
85
+
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
+
4
+ class I18nSimpleBackendLookupTest < Test::Unit::TestCase
5
+ include Tests::Backend::Simple::Setup::Base
6
+
7
+ # useful because this way we can use the backend with no key for interpolation/pluralization
8
+ def test_lookup_given_nil_as_a_key_returns_nil
9
+ assert_nil I18n.backend.send(:lookup, :en, nil)
10
+ end
11
+
12
+ def test_lookup_given_nested_keys_looks_up_a_nested_hash_value
13
+ assert_equal 'bar', I18n.backend.send(:lookup, :en, :bar, [:foo])
14
+ end
15
+
16
+ def test_lookup_using_a_custom_separator
17
+ assert_equal 'bar', I18n.backend.send(:lookup, :en, 'foo|bar', [], '|')
18
+ end
19
+
20
+ def test_default_using_a_custom_separator
21
+ assert_equal 'bar', I18n.backend.send(:default, :en, :'does_not_exist', :'foo|bar', :separator => '|')
22
+ end
23
+ end
@@ -0,0 +1,145 @@
1
+ module Tests
2
+ module Backend
3
+ module Simple
4
+ module Setup
5
+ module Base
6
+ def setup
7
+ super
8
+ I18n.locale = nil
9
+ I18n.default_locale = :en
10
+ I18n.backend = I18n::Backend::Simple.new
11
+ backend_store_translations :en, :foo => {:bar => 'bar', :baz => 'baz'}
12
+ end
13
+
14
+ def teardown
15
+ super
16
+ I18n.load_path = []
17
+ I18n.backend = nil
18
+ end
19
+ end
20
+
21
+ module Localization
22
+ include Base
23
+
24
+ def setup
25
+ super
26
+ setup_datetime_translations
27
+ setup_datetime_lambda_translations
28
+ @old_timezone, ENV['TZ'] = ENV['TZ'], 'UTC'
29
+ end
30
+
31
+ def teardown
32
+ super
33
+ @old_timezone ? ENV['TZ'] = @old_timezone : ENV.delete('TZ')
34
+ end
35
+
36
+ def setup_datetime_translations
37
+ backend_store_translations :de, {
38
+ :date => {
39
+ :formats => {
40
+ :default => "%d.%m.%Y",
41
+ :short => "%d. %b",
42
+ :long => "%d. %B %Y",
43
+ :long_ordinalized => lambda { |date, options|
44
+ tz = " (#{options[:timezone]})" if options[:timezone]
45
+ "#{date.day}ter %B %Y#{tz}"
46
+ }
47
+ },
48
+ :day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
49
+ :abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
50
+ :month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
51
+ :abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil),
52
+ :order => [:day, :month, :year]
53
+ },
54
+ :time => {
55
+ :formats => {
56
+ :default => "%a, %d. %b %Y %H:%M:%S %z",
57
+ :short => "%d. %b %H:%M",
58
+ :long => "%d. %B %Y %H:%M",
59
+ :long_ordinalized => lambda { |date, options|
60
+ tz = " (#{options[:timezone]})" if options[:timezone]
61
+ "#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
62
+ }
63
+ },
64
+ :am => 'am',
65
+ :pm => 'pm'
66
+ },
67
+ :datetime => {
68
+ :distance_in_words => {
69
+ :half_a_minute => 'half a minute',
70
+ :less_than_x_seconds => {
71
+ :one => 'less than 1 second',
72
+ :other => 'less than {{count}} seconds'
73
+ },
74
+ :x_seconds => {
75
+ :one => '1 second',
76
+ :other => '{{count}} seconds'
77
+ },
78
+ :less_than_x_minutes => {
79
+ :one => 'less than a minute',
80
+ :other => 'less than {{count}} minutes'
81
+ },
82
+ :x_minutes => {
83
+ :one => '1 minute',
84
+ :other => '{{count}} minutes'
85
+ },
86
+ :about_x_hours => {
87
+ :one => 'about 1 hour',
88
+ :other => 'about {{count}} hours'
89
+ },
90
+ :x_days => {
91
+ :one => '1 day',
92
+ :other => '{{count}} days'
93
+ },
94
+ :about_x_months => {
95
+ :one => 'about 1 month',
96
+ :other => 'about {{count}} months'
97
+ },
98
+ :x_months => {
99
+ :one => '1 month',
100
+ :other => '{{count}} months'
101
+ },
102
+ :about_x_years => {
103
+ :one => 'about 1 year',
104
+ :other => 'about {{count}} year'
105
+ },
106
+ :over_x_years => {
107
+ :one => 'over 1 year',
108
+ :other => 'over {{count}} years'
109
+ }
110
+ }
111
+ }
112
+ }
113
+ end
114
+
115
+ def setup_datetime_lambda_translations
116
+ backend_store_translations 'ru', {
117
+ :date => {
118
+ :'day_names' => lambda { |key, options|
119
+ (options[:format] =~ /^%A/) ?
120
+ %w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
121
+ %w(воскресенье понедельник вторник среда четверг пятница суббота)
122
+ },
123
+ :'abbr_day_names' => %w(Вс Пн Вт Ср Чт Пт Сб),
124
+ :'month_names' => lambda { |key, options|
125
+ (options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
126
+ %w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
127
+ %w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
128
+ },
129
+ :'abbr_month_names' => lambda { |key, options|
130
+ (options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
131
+ %w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
132
+ %w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
133
+ },
134
+ },
135
+ :time => {
136
+ :am => "утра",
137
+ :pm => "вечера"
138
+ }
139
+ }
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
+
4
+ class I18nSimpleBackendLoadTranslationsTest < Test::Unit::TestCase
5
+ include Tests::Backend::Simple::Setup::Base
6
+
7
+ def test_load_translations_with_unknown_file_type_raises_exception
8
+ assert_raises(I18n::UnknownFileType) { I18n.backend.load_translations "#{locales_dir}/en.xml" }
9
+ end
10
+
11
+ def test_load_translations_with_ruby_file_type_does_not_raise_exception
12
+ assert_nothing_raised { I18n.backend.load_translations "#{locales_dir}/en.rb" }
13
+ end
14
+
15
+ def test_load_rb_loads_data_from_ruby_file
16
+ data = I18n.backend.send :load_rb, "#{locales_dir}/en.rb"
17
+ assert_equal({ :en => { :fuh => { :bah => 'bas' } } }, data)
18
+ end
19
+
20
+ def test_load_rb_loads_data_from_yaml_file
21
+ data = I18n.backend.send :load_yml, "#{locales_dir}/en.yml"
22
+ assert_equal({ 'en' => { 'foo' => { 'bar' => 'baz' } } }, data)
23
+ end
24
+
25
+ def test_load_translations_loads_from_different_file_formats
26
+ I18n.backend = I18n::Backend::Simple.new
27
+ I18n.backend.load_translations "#{locales_dir}/en.rb", "#{locales_dir}/en.yml"
28
+ expected = { :en => { :fuh => { :bah => "bas" }, :foo => { :bar => "baz" } } }
29
+ assert_equal expected, backend_get_translations
30
+ end
31
+ end
32
+
33
+ class I18nSimpleBackendStoreTranslationsTest < Test::Unit::TestCase
34
+ include Tests::Backend::Simple::Setup::Base
35
+
36
+ def test_store_translations_adds_translations # no, really :-)
37
+ I18n.backend.store_translations :'en', :foo => 'bar'
38
+ assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
39
+ end
40
+
41
+ def test_store_translations_deep_merges_translations
42
+ I18n.backend.store_translations :'en', :foo => {:bar => 'bar'}
43
+ I18n.backend.store_translations :'en', :foo => {:baz => 'baz'}
44
+ assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
45
+ end
46
+
47
+ def test_store_translations_forces_locale_to_sym
48
+ I18n.backend.store_translations 'en', :foo => 'bar'
49
+ assert_equal Hash[:'en', {:foo => 'bar'}], backend_get_translations
50
+ end
51
+
52
+ def test_store_translations_converts_keys_to_symbols
53
+ # backend_reset_translations!
54
+ I18n.backend.store_translations 'en', 'foo' => {'bar' => 'bar', 'baz' => 'baz'}
55
+ assert_equal Hash[:'en', {:foo => {:bar => 'bar', :baz => 'baz'}}], backend_get_translations
56
+ end
57
+
58
+ def test_deep_symbolize_keys_works
59
+ result = I18n.backend.send :deep_symbolize_keys, 'foo' => {'bar' => {'baz' => 'bar'}}
60
+ expected = {:foo => {:bar => {:baz => 'bar'}}}
61
+ assert_equal expected, result
62
+ end
63
+ end
64
+
65
+ class I18nSimpleBackendReloadTranslationsTest < Test::Unit::TestCase
66
+ include Tests::Backend::Simple::Setup::Base
67
+
68
+ def setup
69
+ I18n.backend = I18n::Backend::Simple.new
70
+ I18n.load_path = [locales_dir + '/en.yml']
71
+ assert_nil backend_get_translations
72
+ I18n.backend.send :init_translations
73
+ end
74
+
75
+ def test_setup
76
+ assert_not_nil backend_get_translations
77
+ end
78
+
79
+ def test_reload_translations_unloads_translations
80
+ I18n.backend.reload!
81
+ assert_nil backend_get_translations
82
+ end
83
+
84
+ def test_reload_translations_uninitializes_translations
85
+ I18n.backend.reload!
86
+ assert_equal I18n.backend.initialized?, false
87
+ end
88
+ end
@@ -0,0 +1 @@
1
+ { :en => { :fuh => { :bah => "bas" } } }
@@ -0,0 +1,3 @@
1
+ en:
2
+ foo:
3
+ bar: baz
@@ -0,0 +1,95 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
2
+
3
+ class I18nExceptionsTest < Test::Unit::TestCase
4
+ def test_invalid_locale_stores_locale
5
+ force_invalid_locale
6
+ rescue I18n::ArgumentError => e
7
+ assert_nil e.locale
8
+ end
9
+
10
+ def test_invalid_locale_message
11
+ force_invalid_locale
12
+ rescue I18n::ArgumentError => e
13
+ assert_equal 'nil is not a valid locale', e.message
14
+ end
15
+
16
+ def test_missing_translation_data_stores_locale_key_and_options
17
+ force_missing_translation_data
18
+ rescue I18n::ArgumentError => e
19
+ options = {:scope => :bar}
20
+ assert_equal 'de', e.locale
21
+ assert_equal :foo, e.key
22
+ assert_equal options, e.options
23
+ end
24
+
25
+ def test_missing_translation_data_message
26
+ force_missing_translation_data
27
+ rescue I18n::ArgumentError => e
28
+ assert_equal 'translation missing: de, bar, foo', e.message
29
+ end
30
+
31
+ def test_invalid_pluralization_data_stores_entry_and_count
32
+ force_invalid_pluralization_data
33
+ rescue I18n::ArgumentError => e
34
+ assert_equal [:bar], e.entry
35
+ assert_equal 1, e.count
36
+ end
37
+
38
+ def test_invalid_pluralization_data_message
39
+ force_invalid_pluralization_data
40
+ rescue I18n::ArgumentError => e
41
+ assert_equal 'translation data [:bar] can not be used with :count => 1', e.message
42
+ end
43
+
44
+ def test_missing_interpolation_argument_stores_key_and_string
45
+ assert_raises(I18n::MissingInterpolationArgument) { force_missing_interpolation_argument }
46
+ force_missing_interpolation_argument
47
+ rescue I18n::ArgumentError => e
48
+ # assert_equal :bar, e.key
49
+ assert_equal "{{bar}}", e.string
50
+ end
51
+
52
+ def test_missing_interpolation_argument_message
53
+ force_missing_interpolation_argument
54
+ rescue I18n::ArgumentError => e
55
+ assert_equal 'missing interpolation argument in "{{bar}}" ({:baz=>"baz"} given)', e.message
56
+ end
57
+
58
+ def test_reserved_interpolation_key_stores_key_and_string
59
+ force_reserved_interpolation_key
60
+ rescue I18n::ArgumentError => e
61
+ assert_equal :scope, e.key
62
+ assert_equal "{{scope}}", e.string
63
+ end
64
+
65
+ def test_reserved_interpolation_key_message
66
+ force_reserved_interpolation_key
67
+ rescue I18n::ArgumentError => e
68
+ assert_equal 'reserved key :scope used in "{{scope}}"', e.message
69
+ end
70
+
71
+ private
72
+ def force_invalid_locale
73
+ I18n.backend.translate nil, :foo
74
+ end
75
+
76
+ def force_missing_translation_data
77
+ I18n.backend.store_translations 'de', :bar => nil
78
+ I18n.backend.translate 'de', :foo, :scope => :bar
79
+ end
80
+
81
+ def force_invalid_pluralization_data
82
+ I18n.backend.store_translations 'de', :foo => [:bar]
83
+ I18n.backend.translate 'de', :foo, :count => 1
84
+ end
85
+
86
+ def force_missing_interpolation_argument
87
+ I18n.backend.store_translations 'de', :foo => "{{bar}}"
88
+ I18n.backend.translate 'de', :foo, :baz => 'baz'
89
+ end
90
+
91
+ def force_reserved_interpolation_key
92
+ I18n.backend.store_translations 'de', :foo => "{{scope}}"
93
+ I18n.backend.translate 'de', :foo, :baz => 'baz'
94
+ end
95
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/test_helper')
3
+
4
+ class I18nLoadPathTest < Test::Unit::TestCase
5
+ # include Tests::Backend::Simple::Setup::Base
6
+
7
+ def setup
8
+ I18n.locale = :en
9
+ I18n.backend = I18n::Backend::Simple.new
10
+ backend_store_translations(:en, :foo => {:bar => 'bar', :baz => 'baz'})
11
+ end
12
+
13
+ def test_nested_load_paths_do_not_break_locale_loading
14
+ I18n.load_path = [[locales_dir + '/en.yml']]
15
+ assert_equal "baz", I18n.t(:'foo.bar')
16
+ end
17
+
18
+ def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading
19
+ I18n.load_path << Dir[locales_dir + '/*.{rb,yml}']
20
+ assert_equal "baz", I18n.t(:'foo.bar')
21
+ end
22
+ end