i18n 0.2.0 → 0.2.1

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.

@@ -1,61 +1,61 @@
1
- module Tests
2
- module Backend
3
- module Api
4
- module Localization
5
- module Time
6
- # TODO should be Mrz, shouldn't it?
7
- def test_localize_given_the_short_format_it_uses_it
8
- assert_equal '01. Mar 06:00', I18n.backend.localize('de', morning_time, :short)
9
- end
10
-
11
- def test_localize_given_the_long_format_it_uses_it
12
- assert_equal '01. März 2008 06:00', I18n.backend.localize('de', morning_time, :long)
13
- end
14
-
15
- # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
16
- # def test_localize_given_the_default_format_it_uses_it
17
- # assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.backend.localize('de', morning_time, :default)
18
- # end
19
-
20
- def test_localize_given_a_day_name_format_it_returns_the_correct_day_name
21
- assert_equal 'Samstag', I18n.backend.localize('de', morning_time, '%A')
22
- end
23
-
24
- def test_localize_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
25
- assert_equal 'Sa', I18n.backend.localize('de', morning_time, '%a')
26
- end
27
-
28
- def test_localize_given_a_month_name_format_it_returns_the_correct_month_name
29
- assert_equal 'März', I18n.backend.localize('de', morning_time, '%B')
30
- end
31
-
32
- # TODO should be Mrz, shouldn't it?
33
- def test_localize_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
34
- assert_equal 'Mar', I18n.backend.localize('de', morning_time, '%b')
35
- end
36
-
37
- def test_localize_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
38
- assert_equal 'am', I18n.backend.localize('de', morning_time, '%p')
39
- assert_equal 'pm', I18n.backend.localize('de', evening_time, '%p')
40
- end
41
-
42
- def test_localize_given_a_format_specified_as_a_proc
43
- assert_equal '1ter März 2008, 06:00 Uhr', I18n.backend.localize('de', morning_time, :long_ordinalized)
44
- end
45
-
46
- def test_localize_given_a_format_specified_as_a_proc_with_additional_options
47
- assert_equal '1ter März 2008, 06:00 Uhr (MEZ)', I18n.backend.localize('de', morning_time, :long_ordinalized, :timezone => 'MEZ')
48
- end
49
-
50
- def test_localize_given_no_format_it_does_not_fail
51
- assert_nothing_raised{ I18n.backend.localize 'de', morning_time }
52
- end
53
-
54
- def test_localize_given_an_unknown_format_it_does_not_fail
55
- assert_nothing_raised{ I18n.backend.localize 'de', morning_time, '%x' }
56
- end
57
- end
58
- end
59
- end
60
- end
1
+ module Tests
2
+ module Backend
3
+ module Api
4
+ module Localization
5
+ module Time
6
+ # TODO should be Mrz, shouldn't it?
7
+ def test_localize_given_the_short_format_it_uses_it
8
+ assert_equal '01. Mar 06:00', I18n.backend.localize('de', morning_time, :short)
9
+ end
10
+
11
+ def test_localize_given_the_long_format_it_uses_it
12
+ assert_equal '01. März 2008 06:00', I18n.backend.localize('de', morning_time, :long)
13
+ end
14
+
15
+ # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
16
+ # def test_localize_given_the_default_format_it_uses_it
17
+ # assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.backend.localize('de', morning_time, :default)
18
+ # end
19
+
20
+ def test_localize_given_a_day_name_format_it_returns_the_correct_day_name
21
+ assert_equal 'Samstag', I18n.backend.localize('de', morning_time, '%A')
22
+ end
23
+
24
+ def test_localize_given_an_abbr_day_name_format_it_returns_the_correct_abbrevated_day_name
25
+ assert_equal 'Sa', I18n.backend.localize('de', morning_time, '%a')
26
+ end
27
+
28
+ def test_localize_given_a_month_name_format_it_returns_the_correct_month_name
29
+ assert_equal 'März', I18n.backend.localize('de', morning_time, '%B')
30
+ end
31
+
32
+ # TODO should be Mrz, shouldn't it?
33
+ def test_localize_given_an_abbr_month_name_format_it_returns_the_correct_abbrevated_month_name
34
+ assert_equal 'Mar', I18n.backend.localize('de', morning_time, '%b')
35
+ end
36
+
37
+ def test_localize_given_a_meridian_indicator_format_it_returns_the_correct_meridian_indicator
38
+ assert_equal 'am', I18n.backend.localize('de', morning_time, '%p')
39
+ assert_equal 'pm', I18n.backend.localize('de', evening_time, '%p')
40
+ end
41
+
42
+ def test_localize_given_a_format_specified_as_a_proc
43
+ assert_equal '1ter März 2008, 06:00 Uhr', I18n.backend.localize('de', morning_time, :long_ordinalized)
44
+ end
45
+
46
+ def test_localize_given_a_format_specified_as_a_proc_with_additional_options
47
+ assert_equal '1ter März 2008, 06:00 Uhr (MEZ)', I18n.backend.localize('de', morning_time, :long_ordinalized, :timezone => 'MEZ')
48
+ end
49
+
50
+ def test_localize_given_no_format_it_does_not_fail
51
+ assert_nothing_raised{ I18n.backend.localize 'de', morning_time }
52
+ end
53
+
54
+ def test_localize_given_an_unknown_format_it_does_not_fail
55
+ assert_nothing_raised{ I18n.backend.localize 'de', morning_time, '%x' }
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
61
  end
@@ -1,40 +1,40 @@
1
- module Tests
2
- module Backend
3
- module Api
4
- module Pluralization
5
- def test_pluralize_given_nil_returns_the_given_entry
6
- entry = {:one => 'bar', :other => 'bars'}
7
- assert_equal entry, I18n.backend.send(:pluralize, nil, entry, nil)
8
- end
9
-
10
- def test_pluralize_given_0_returns_zero_string_if_zero_key_given
11
- assert_equal 'zero', I18n.backend.send(:pluralize, nil, {:zero => 'zero', :one => 'bar', :other => 'bars'}, 0)
12
- end
13
-
14
- def test_pluralize_given_0_returns_plural_string_if_no_zero_key_given
15
- assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 0)
16
- end
17
-
18
- def test_pluralize_given_1_returns_singular_string
19
- assert_equal 'bar', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 1)
20
- end
21
-
22
- def test_pluralize_given_2_returns_plural_string
23
- assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 2)
24
- end
25
-
26
- def test_pluralize_given_3_returns_plural_string
27
- assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 3)
28
- end
29
-
30
- def test_interpolate_given_incomplete_pluralization_data_raises_invalid_pluralization_data
31
- assert_raises(I18n::InvalidPluralizationData){ I18n.backend.send(:pluralize, nil, {:one => 'bar'}, 2) }
32
- end
33
-
34
- def test_pluralize_given_pluralization_data_as_default
35
- assert_equal 'bars', I18n.t(:bar, :count => 2, :default => { :one => 'bar', :other => 'bars' })
36
- end
37
- end
38
- end
39
- end
1
+ module Tests
2
+ module Backend
3
+ module Api
4
+ module Pluralization
5
+ def test_pluralize_given_nil_returns_the_given_entry
6
+ entry = {:one => 'bar', :other => 'bars'}
7
+ assert_equal entry, I18n.backend.send(:pluralize, nil, entry, nil)
8
+ end
9
+
10
+ def test_pluralize_given_0_returns_zero_string_if_zero_key_given
11
+ assert_equal 'zero', I18n.backend.send(:pluralize, nil, {:zero => 'zero', :one => 'bar', :other => 'bars'}, 0)
12
+ end
13
+
14
+ def test_pluralize_given_0_returns_plural_string_if_no_zero_key_given
15
+ assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 0)
16
+ end
17
+
18
+ def test_pluralize_given_1_returns_singular_string
19
+ assert_equal 'bar', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 1)
20
+ end
21
+
22
+ def test_pluralize_given_2_returns_plural_string
23
+ assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 2)
24
+ end
25
+
26
+ def test_pluralize_given_3_returns_plural_string
27
+ assert_equal 'bars', I18n.backend.send(:pluralize, nil, {:one => 'bar', :other => 'bars'}, 3)
28
+ end
29
+
30
+ def test_interpolate_given_incomplete_pluralization_data_raises_invalid_pluralization_data
31
+ assert_raises(I18n::InvalidPluralizationData){ I18n.backend.send(:pluralize, nil, {:one => 'bar'}, 2) }
32
+ end
33
+
34
+ def test_pluralize_given_pluralization_data_as_default
35
+ assert_equal 'bars', I18n.t(:bar, :count => 2, :default => { :one => 'bar', :other => 'bars' })
36
+ end
37
+ end
38
+ end
39
+ end
40
40
  end
@@ -1,49 +1,49 @@
1
- module Tests
2
- module Backend
3
- module Api
4
- module Translation
5
- def translate(key, options = {})
6
- I18n.backend.translate('en', key, options)
7
- end
8
-
9
- def test_given_no_keys_it_returns_the_default
10
- assert_equal 'default', translate(nil, :default => 'default')
11
- end
12
-
13
- def test_translate_given_a_symbol_as_a_default_translates_the_symbol
14
- assert_equal 'bar', translate(nil, :default => :'foo.bar')
15
- end
16
-
17
- def test_translate_default_with_scope_stays_in_scope_when_looking_up_the_symbol
18
- assert_equal 'bar', translate(:missing, :default => :bar, :scope => :foo)
19
- end
20
-
21
- def test_translate_given_an_array_as_default_uses_the_first_match
22
- assert_equal 'bar', translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
23
- end
24
-
25
- def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data
26
- assert_raises I18n::MissingTranslationData do
27
- translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
28
- end
29
- end
30
-
31
- def test_translate_an_array_of_keys_translates_all_of_them
32
- assert_equal %w(bar baz), translate([:bar, :baz], :scope => [:foo])
33
- end
34
-
35
- def test_translate_with_a_missing_key_and_no_default_raises_missing_translation_data
36
- assert_raises(I18n::MissingTranslationData) do
37
- translate(:missing)
38
- end
39
- end
40
-
41
- def test_translate_given_nil_as_a_locale_raises_an_argument_error
42
- assert_raises(I18n::InvalidLocale) do
43
- I18n.backend.translate(nil, :bar)
44
- end
45
- end
46
- end
47
- end
48
- end
1
+ module Tests
2
+ module Backend
3
+ module Api
4
+ module Translation
5
+ def translate(key, options = {})
6
+ I18n.backend.translate('en', key, options)
7
+ end
8
+
9
+ def test_given_no_keys_it_returns_the_default
10
+ assert_equal 'default', translate(nil, :default => 'default')
11
+ end
12
+
13
+ def test_translate_given_a_symbol_as_a_default_translates_the_symbol
14
+ assert_equal 'bar', translate(nil, :default => :'foo.bar')
15
+ end
16
+
17
+ def test_translate_default_with_scope_stays_in_scope_when_looking_up_the_symbol
18
+ assert_equal 'bar', translate(:missing, :default => :bar, :scope => :foo)
19
+ end
20
+
21
+ def test_translate_given_an_array_as_default_uses_the_first_match
22
+ assert_equal 'bar', translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :bar])
23
+ end
24
+
25
+ def test_translate_given_an_array_of_inexistent_keys_it_raises_missing_translation_data
26
+ assert_raises I18n::MissingTranslationData do
27
+ translate(:does_not_exist, :scope => [:foo], :default => [:does_not_exist_2, :does_not_exist_3])
28
+ end
29
+ end
30
+
31
+ def test_translate_an_array_of_keys_translates_all_of_them
32
+ assert_equal %w(bar baz), translate([:bar, :baz], :scope => [:foo])
33
+ end
34
+
35
+ def test_translate_with_a_missing_key_and_no_default_raises_missing_translation_data
36
+ assert_raises(I18n::MissingTranslationData) do
37
+ translate(:missing)
38
+ end
39
+ end
40
+
41
+ def test_translate_given_nil_as_a_locale_raises_an_argument_error
42
+ assert_raises(I18n::InvalidLocale) do
43
+ I18n.backend.translate(nil, :bar)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
49
  end
@@ -1,3 +1,3 @@
1
- Dir[File.dirname(__FILE__) + '/*_test.rb'].each do |file|
2
- require file
3
- end
1
+ Dir[File.dirname(__FILE__) + '/*_test.rb'].each do |file|
2
+ require file
3
+ end
@@ -1,85 +1,85 @@
1
- # encoding: utf-8
2
- require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
-
4
- class I18nSimpleBackendApiTest < Test::Unit::TestCase
5
- include Tests::Backend::Simple::Setup::Base
6
- include Tests::Backend::Api::Basics
7
- end
8
-
9
- class I18nSimpleBackendTranslateTest < 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 I18nSimpleBackendInterpolateTest < 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 I18nSimpleBackendLambdaTest < Test::Unit::TestCase
52
- include Tests::Backend::Simple::Setup::Base
53
- include Tests::Backend::Api::Lambda
54
- end
55
-
56
- class I18nSimpleBackendTranslateLinkedTest < Test::Unit::TestCase
57
- include Tests::Backend::Simple::Setup::Base
58
- include Tests::Backend::Api::Link
59
- end
60
-
61
- class I18nSimpleBackendPluralizationTest < Test::Unit::TestCase
62
- include Tests::Backend::Simple::Setup::Base
63
- include Tests::Backend::Api::Pluralization
64
- end
65
-
66
- class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase
67
- include Tests::Backend::Simple::Setup::Localization
68
- include Tests::Backend::Api::Localization::Date
69
- end
70
-
71
- class I18nSimpleBackendLocalizeDateTimeTest < Test::Unit::TestCase
72
- include Tests::Backend::Simple::Setup::Localization
73
- include Tests::Backend::Api::Localization::DateTime
74
- end
75
-
76
- class I18nSimpleBackendLocalizeTimeTest < Test::Unit::TestCase
77
- include Tests::Backend::Simple::Setup::Localization
78
- include Tests::Backend::Api::Localization::Time
79
- end
80
-
81
- class I18nSimpleBackendLocalizeLambdaTest < Test::Unit::TestCase
82
- include Tests::Backend::Simple::Setup::Localization
83
- include Tests::Backend::Api::Localization::Lambda
84
- end
85
-
1
+ # encoding: utf-8
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
3
+
4
+ class I18nSimpleBackendApiTest < Test::Unit::TestCase
5
+ include Tests::Backend::Simple::Setup::Base
6
+ include Tests::Backend::Api::Basics
7
+ end
8
+
9
+ class I18nSimpleBackendTranslateTest < 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 I18nSimpleBackendInterpolateTest < 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 I18nSimpleBackendLambdaTest < Test::Unit::TestCase
52
+ include Tests::Backend::Simple::Setup::Base
53
+ include Tests::Backend::Api::Lambda
54
+ end
55
+
56
+ class I18nSimpleBackendTranslateLinkedTest < Test::Unit::TestCase
57
+ include Tests::Backend::Simple::Setup::Base
58
+ include Tests::Backend::Api::Link
59
+ end
60
+
61
+ class I18nSimpleBackendPluralizationTest < Test::Unit::TestCase
62
+ include Tests::Backend::Simple::Setup::Base
63
+ include Tests::Backend::Api::Pluralization
64
+ end
65
+
66
+ class I18nSimpleBackendLocalizeDateTest < Test::Unit::TestCase
67
+ include Tests::Backend::Simple::Setup::Localization
68
+ include Tests::Backend::Api::Localization::Date
69
+ end
70
+
71
+ class I18nSimpleBackendLocalizeDateTimeTest < Test::Unit::TestCase
72
+ include Tests::Backend::Simple::Setup::Localization
73
+ include Tests::Backend::Api::Localization::DateTime
74
+ end
75
+
76
+ class I18nSimpleBackendLocalizeTimeTest < Test::Unit::TestCase
77
+ include Tests::Backend::Simple::Setup::Localization
78
+ include Tests::Backend::Api::Localization::Time
79
+ end
80
+
81
+ class I18nSimpleBackendLocalizeLambdaTest < Test::Unit::TestCase
82
+ include Tests::Backend::Simple::Setup::Localization
83
+ include Tests::Backend::Api::Localization::Lambda
84
+ end
85
+