yaroslav-russian 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -3
- data/Rakefile +1 -1
- data/TODO +1 -0
- data/lib/russian/locale/actionview.yml +0 -1
- data/lib/russian/locale/activerecord.yml +1 -1
- data/lib/russian/locale/activesupport.yml +1 -0
- data/lib/russian.rb +1 -1
- data/lib/vendor/i18n/README.textile +2 -0
- data/lib/vendor/i18n/i18n.gemspec +21 -18
- data/lib/vendor/i18n/lib/i18n/backend/simple.rb +70 -52
- data/lib/vendor/i18n/lib/i18n/exceptions.rb +3 -3
- data/lib/vendor/i18n/lib/i18n.rb +53 -44
- data/lib/vendor/i18n/test/all.rb +1 -1
- data/lib/vendor/i18n/test/i18n_exceptions_test.rb +14 -14
- data/lib/vendor/i18n/test/i18n_test.rb +23 -23
- data/lib/vendor/i18n/test/simple_backend_test.rb +121 -92
- data/spec/locale_spec.rb +0 -1
- metadata +2 -2
@@ -12,13 +12,13 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
12
12
|
rescue I18n::ArgumentError => e
|
13
13
|
assert_nil e.locale
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_invalid_locale_message
|
17
17
|
force_invalid_locale
|
18
18
|
rescue I18n::ArgumentError => e
|
19
19
|
assert_equal 'nil is not a valid locale', e.message
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def test_missing_translation_data_stores_locale_key_and_options
|
23
23
|
force_missing_translation_data
|
24
24
|
rescue I18n::ArgumentError => e
|
@@ -27,72 +27,72 @@ class I18nExceptionsTest < Test::Unit::TestCase
|
|
27
27
|
assert_equal :foo, e.key
|
28
28
|
assert_equal options, e.options
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def test_missing_translation_data_message
|
32
32
|
force_missing_translation_data
|
33
33
|
rescue I18n::ArgumentError => e
|
34
34
|
assert_equal 'translation missing: de-DE, bar, foo', e.message
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_invalid_pluralization_data_stores_entry_and_count
|
38
38
|
force_invalid_pluralization_data
|
39
39
|
rescue I18n::ArgumentError => e
|
40
40
|
assert_equal [:bar], e.entry
|
41
41
|
assert_equal 1, e.count
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def test_invalid_pluralization_data_message
|
45
45
|
force_invalid_pluralization_data
|
46
46
|
rescue I18n::ArgumentError => e
|
47
47
|
assert_equal 'translation data [:bar] can not be used with :count => 1', e.message
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_missing_interpolation_argument_stores_key_and_string
|
51
51
|
force_missing_interpolation_argument
|
52
52
|
rescue I18n::ArgumentError => e
|
53
53
|
assert_equal 'bar', e.key
|
54
54
|
assert_equal "{{bar}}", e.string
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def test_missing_interpolation_argument_message
|
58
58
|
force_missing_interpolation_argument
|
59
59
|
rescue I18n::ArgumentError => e
|
60
60
|
assert_equal 'interpolation argument bar missing in "{{bar}}"', e.message
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def test_reserved_interpolation_key_stores_key_and_string
|
64
64
|
force_reserved_interpolation_key
|
65
65
|
rescue I18n::ArgumentError => e
|
66
66
|
assert_equal 'scope', e.key
|
67
67
|
assert_equal "{{scope}}", e.string
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def test_reserved_interpolation_key_message
|
71
71
|
force_reserved_interpolation_key
|
72
72
|
rescue I18n::ArgumentError => e
|
73
73
|
assert_equal 'reserved key "scope" used in "{{scope}}"', e.message
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
private
|
77
77
|
def force_invalid_locale
|
78
78
|
I18n.backend.translate nil, :foo
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def force_missing_translation_data
|
82
82
|
I18n.backend.store_translations 'de-DE', :bar => nil
|
83
83
|
I18n.backend.translate 'de-DE', :foo, :scope => :bar
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def force_invalid_pluralization_data
|
87
87
|
I18n.backend.store_translations 'de-DE', :foo => [:bar]
|
88
88
|
I18n.backend.translate 'de-DE', :foo, :count => 1
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def force_missing_interpolation_argument
|
92
92
|
I18n.backend.store_translations 'de-DE', :foo => "{{bar}}"
|
93
93
|
I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
def force_reserved_interpolation_key
|
97
97
|
I18n.backend.store_translations 'de-DE', :foo => "{{scope}}"
|
98
98
|
I18n.backend.translate 'de-DE', :foo, :baz => 'baz'
|
@@ -17,108 +17,108 @@ class I18nTest < Test::Unit::TestCase
|
|
17
17
|
}
|
18
18
|
}
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def test_uses_simple_backend_set_by_default
|
22
22
|
assert I18n.backend.is_a?(I18n::Backend::Simple)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def test_can_set_backend
|
26
26
|
assert_nothing_raised{ I18n.backend = self }
|
27
27
|
assert_equal self, I18n.backend
|
28
28
|
I18n.backend = I18n::Backend::Simple.new
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def test_uses_en_us_as_default_locale_by_default
|
32
32
|
assert_equal 'en-US', I18n.default_locale
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def test_can_set_default_locale
|
36
36
|
assert_nothing_raised{ I18n.default_locale = 'de-DE' }
|
37
37
|
assert_equal 'de-DE', I18n.default_locale
|
38
38
|
I18n.default_locale = 'en-US'
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def test_uses_default_locale_as_locale_by_default
|
42
42
|
assert_equal I18n.default_locale, I18n.locale
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def test_can_set_locale_to_thread_current
|
46
46
|
assert_nothing_raised{ I18n.locale = 'de-DE' }
|
47
47
|
assert_equal 'de-DE', I18n.locale
|
48
48
|
assert_equal 'de-DE', Thread.current[:locale]
|
49
49
|
I18n.locale = 'en-US'
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def test_can_set_exception_handler
|
53
53
|
assert_nothing_raised{ I18n.exception_handler = :custom_exception_handler }
|
54
54
|
I18n.exception_handler = :default_exception_handler # revert it
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def test_uses_custom_exception_handler
|
58
58
|
I18n.exception_handler = :custom_exception_handler
|
59
59
|
I18n.expects(:custom_exception_handler)
|
60
60
|
I18n.translate :bogus
|
61
61
|
I18n.exception_handler = :default_exception_handler # revert it
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def test_delegates_translate_to_backend
|
65
65
|
I18n.backend.expects(:translate).with 'de-DE', :foo, {}
|
66
66
|
I18n.translate :foo, :locale => 'de-DE'
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
def test_delegates_localize_to_backend
|
70
70
|
I18n.backend.expects(:localize).with 'de-DE', :whatever, :default
|
71
71
|
I18n.localize :whatever, :locale => 'de-DE'
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
def test_translate_given_no_locale_uses_i18n_locale
|
75
75
|
I18n.backend.expects(:translate).with 'en-US', :foo, {}
|
76
76
|
I18n.translate :foo
|
77
|
-
end
|
78
|
-
|
77
|
+
end
|
78
|
+
|
79
79
|
def test_translate_on_nested_symbol_keys_works
|
80
80
|
assert_equal ".", I18n.t(:'currency.format.separator')
|
81
81
|
end
|
82
|
-
|
82
|
+
|
83
83
|
def test_translate_with_nested_string_keys_works
|
84
84
|
assert_equal ".", I18n.t('currency.format.separator')
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def test_translate_with_array_as_scope_works
|
88
88
|
assert_equal ".", I18n.t(:separator, :scope => ['currency.format'])
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def test_translate_with_array_containing_dot_separated_strings_as_scope_works
|
92
92
|
assert_equal ".", I18n.t(:separator, :scope => ['currency.format'])
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def test_translate_with_key_array_and_dot_separated_scope_works
|
96
96
|
assert_equal [".", ","], I18n.t(%w(separator delimiter), :scope => 'currency.format')
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
def test_translate_with_dot_separated_key_array_and_scope_works
|
100
100
|
assert_equal [".", ","], I18n.t(%w(format.separator format.delimiter), :scope => 'currency')
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
def test_translate_with_options_using_scope_works
|
104
104
|
I18n.backend.expects(:translate).with('de-DE', :precision, :scope => :"currency.format")
|
105
105
|
I18n.with_options :locale => 'de-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
111
|
# assert_equal "translation missing: en-US, no key", I18n.t
|
112
112
|
# end
|
113
|
-
|
113
|
+
|
114
114
|
def test_translate_given_a_bogus_key_raises_missing_translation_data
|
115
115
|
assert_equal "translation missing: en-US, bogus", I18n.t(:bogus)
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
def test_localize_nil_raises_argument_error
|
119
119
|
assert_raises(I18n::ArgumentError) { I18n.l nil }
|
120
120
|
end
|
121
|
-
|
121
|
+
|
122
122
|
def test_localize_object_raises_argument_error
|
123
123
|
assert_raises(I18n::ArgumentError) { I18n.l Object.new }
|
124
124
|
end
|