activesupport 2.3.6.pre → 2.3.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +9 -5
- data/lib/active_support/buffered_logger.rb +1 -1
- data/lib/active_support/cache/memory_store.rb +7 -1
- data/lib/active_support/cache/strategy/local_cache.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +1 -1
- data/lib/active_support/core_ext/array/random_access.rb +11 -1
- data/lib/active_support/core_ext/class/attribute_accessors.rb +35 -28
- data/lib/active_support/core_ext/date/calculations.rb +14 -4
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attribute_accessors.rb +33 -26
- data/lib/active_support/core_ext/module/synchronization.rb +1 -1
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/string/output_safety.rb +10 -2
- data/lib/active_support/core_ext/string/starts_ends_with.rb +2 -4
- data/lib/active_support/core_ext/time.rb +8 -4
- data/lib/active_support/core_ext/time/calculations.rb +11 -2
- data/lib/active_support/deprecation.rb +3 -2
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +4 -1
- data/lib/active_support/json/backends/yaml.rb +10 -7
- data/lib/active_support/json/decoding.rb +1 -1
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/multibyte/unicode_database.rb +2 -2
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/ordered_hash.rb +24 -30
- data/lib/active_support/testing/assertions.rb +14 -0
- data/lib/active_support/values/time_zone.rb +84 -76
- data/lib/active_support/vendor.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n.rb +92 -34
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend.rb +2 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record.rb +9 -13
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/missing.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/store_procs.rb +6 -6
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/active_record/translation.rb +14 -9
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/base.rb +23 -16
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cache.rb +1 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/cascade.rb +22 -8
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/chain.rb +2 -1
- data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/cldr.rb +100 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fallbacks.rb +20 -3
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/fast.rb +14 -13
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/gettext.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/helpers.rb +4 -16
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/interpolation_compiler.rb +2 -2
- data/lib/active_support/vendor/i18n-0.3.7/i18n/backend/links.rb +34 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/metadata.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/pluralization.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/backend/simple.rb +0 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/except.rb +8 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/core_ext/hash/slice.rb +8 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/object/meta_class.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/core_ext/string/interpolate.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/exceptions.rb +1 -1
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/gettext.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/vendor → i18n-0.3.7/i18n/gettext}/po_parser.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/helpers/gettext.rb +3 -2
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/fallbacks.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/parents.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/rfc4646.rb +0 -0
- data/lib/active_support/vendor/{i18n-0.3.3/lib → i18n-0.3.7}/i18n/locale/tag/simple.rb +0 -0
- data/lib/active_support/vendor/i18n-0.3.7/i18n/version.rb +3 -0
- metadata +42 -96
- data/lib/active_support/vendor/i18n-0.3.3/CHANGELOG.textile +0 -76
- data/lib/active_support/vendor/i18n-0.3.3/MIT-LICENSE +0 -20
- data/lib/active_support/vendor/i18n-0.3.3/README.textile +0 -81
- data/lib/active_support/vendor/i18n-0.3.3/Rakefile +0 -24
- data/lib/active_support/vendor/i18n-0.3.3/benchmark/example.yml +0 -144
- data/lib/active_support/vendor/i18n-0.3.3/benchmark/run.rb +0 -71
- data/lib/active_support/vendor/i18n-0.3.3/contributors.txt +0 -17
- data/lib/active_support/vendor/i18n-0.3.3/i18n.gemspec +0 -165
- data/lib/active_support/vendor/i18n-0.3.3/init.rb +0 -1
- data/lib/active_support/vendor/i18n-0.3.3/lib/i18n/version.rb +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/all.rb +0 -8
- data/lib/active_support/vendor/i18n-0.3.3/test/api/basics.rb +0 -15
- data/lib/active_support/vendor/i18n-0.3.3/test/api/defaults.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/api/interpolation.rb +0 -92
- data/lib/active_support/vendor/i18n-0.3.3/test/api/link.rb +0 -55
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date.rb +0 -91
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/date_time.rb +0 -90
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/procs.rb +0 -54
- data/lib/active_support/vendor/i18n-0.3.3/test/api/localization/time.rb +0 -84
- data/lib/active_support/vendor/i18n-0.3.3/test/api/lookup.rb +0 -45
- data/lib/active_support/vendor/i18n-0.3.3/test/api/pluralization.rb +0 -35
- data/lib/active_support/vendor/i18n-0.3.3/test/api/procs.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/active_record_test.rb +0 -29
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/all_features_test.rb +0 -40
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/cascade_test.rb +0 -31
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/chain_test.rb +0 -26
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fallbacks_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/fast_test.rb +0 -31
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/pluralization_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/api/simple_test.rb +0 -21
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record/missing_test.rb +0 -60
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/active_record_test.rb +0 -52
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cache_test.rb +0 -72
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/cascade_test.rb +0 -66
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/chain_test.rb +0 -64
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fallbacks_test.rb +0 -57
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/fast_test.rb +0 -50
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/helpers_test.rb +0 -26
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/interpolation_compiler_test.rb +0 -107
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/metadata_test.rb +0 -67
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/pluralization_test.rb +0 -43
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/backend/simple_test.rb +0 -77
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/core_ext/string/interpolate_test.rb +0 -94
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/api_test.rb +0 -201
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/gettext/backend_test.rb +0 -91
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_exceptions_test.rb +0 -97
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_load_path_test.rb +0 -23
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/i18n_test.rb +0 -172
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/fallbacks_test.rb +0 -126
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/rfc4646_test.rb +0 -143
- data/lib/active_support/vendor/i18n-0.3.3/test/cases/locale/tag/simple_test.rb +0 -33
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/de.po +0 -72
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.rb +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/en.yml +0 -3
- data/lib/active_support/vendor/i18n-0.3.3/test/fixtures/locales/plurals.rb +0 -113
- data/lib/active_support/vendor/i18n-0.3.3/test/test_helper.rb +0 -100
@@ -1,91 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Localization
|
6
|
-
module Date
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
setup_date_translations
|
10
|
-
@date = ::Date.new(2008, 3, 1)
|
11
|
-
end
|
12
|
-
|
13
|
-
define_method "test localize Date: given the short format it uses it" do
|
14
|
-
# TODO should be Mrz, shouldn't it?
|
15
|
-
assert_equal '01. Mar', I18n.l(@date, :format => :short, :locale => :de)
|
16
|
-
end
|
17
|
-
|
18
|
-
define_method "test localize Date: given the long format it uses it" do
|
19
|
-
assert_equal '01. März 2008', I18n.l(@date, :format => :long, :locale => :de)
|
20
|
-
end
|
21
|
-
|
22
|
-
define_method "test localize Date: given the default format it uses it" do
|
23
|
-
assert_equal '01.03.2008', I18n.l(@date, :format => :default, :locale => :de)
|
24
|
-
end
|
25
|
-
|
26
|
-
define_method "test localize Date: given a day name format it returns the correct day name" do
|
27
|
-
assert_equal 'Samstag', I18n.l(@date, :format => '%A', :locale => :de)
|
28
|
-
end
|
29
|
-
|
30
|
-
define_method "test localize Date: given an abbreviated day name format it returns the correct abbreviated day name" do
|
31
|
-
assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de)
|
32
|
-
end
|
33
|
-
|
34
|
-
define_method "test localize Date: given a month name format it returns the correct month name" do
|
35
|
-
assert_equal 'März', I18n.l(@date, :format => '%B', :locale => :de)
|
36
|
-
end
|
37
|
-
|
38
|
-
define_method "test localize Date: given an abbreviated month name format it returns the correct abbreviated month name" do
|
39
|
-
# TODO should be Mrz, shouldn't it?
|
40
|
-
assert_equal 'Mar', I18n.l(@date, :format => '%b', :locale => :de)
|
41
|
-
end
|
42
|
-
|
43
|
-
define_method "test localize Date: given a format that resolves to a Proc it calls the Proc with the object" do
|
44
|
-
# TODO should be Mrz, shouldn't it?
|
45
|
-
assert_equal '[Sat, 01 Mar 2008, {}]', I18n.l(@date, :format => :proc, :locale => :de)
|
46
|
-
end
|
47
|
-
|
48
|
-
# TODO fails, but something along these lines probably should pass
|
49
|
-
# define_method "test localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
50
|
-
# assert_equal '[Sat Mar 01 06:00:00 UTC 2008, {:foo=>"foo"}]', I18n.l(@time, :format => :proc, :foo => 'foo', :locale => :de)
|
51
|
-
# end
|
52
|
-
|
53
|
-
define_method "test localize Date: given an unknown format it does not fail" do
|
54
|
-
assert_nothing_raised { I18n.l(@date, :format => '%x') }
|
55
|
-
end
|
56
|
-
|
57
|
-
define_method "test localize Date: given nil it raises I18n::ArgumentError" do
|
58
|
-
assert_raises(I18n::ArgumentError) { I18n.l(nil) }
|
59
|
-
end
|
60
|
-
|
61
|
-
define_method "test localize Date: given a plain Object it raises I18n::ArgumentError" do
|
62
|
-
assert_raises(I18n::ArgumentError) { I18n.l(Object.new) }
|
63
|
-
end
|
64
|
-
|
65
|
-
define_method "test localize Date: it does not alter the format string" do
|
66
|
-
assert_equal '01. Februar 2009', I18n.l(::Date.parse('2009-02-01'), :format => :long, :locale => :de)
|
67
|
-
assert_equal '01. Oktober 2009', I18n.l(::Date.parse('2009-10-01'), :format => :long, :locale => :de)
|
68
|
-
end
|
69
|
-
|
70
|
-
protected
|
71
|
-
|
72
|
-
def setup_date_translations
|
73
|
-
store_translations :de, {
|
74
|
-
:date => {
|
75
|
-
:formats => {
|
76
|
-
:default => "%d.%m.%Y",
|
77
|
-
:short => "%d. %b",
|
78
|
-
:long => "%d. %B %Y",
|
79
|
-
:proc => lambda { |*args| args.inspect }
|
80
|
-
},
|
81
|
-
:day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
|
82
|
-
:abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
|
83
|
-
:month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
|
84
|
-
:abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
|
85
|
-
}
|
86
|
-
}
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Localization
|
6
|
-
module DateTime
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
setup_datetime_translations
|
10
|
-
@datetime = ::DateTime.new(2008, 3, 1, 6)
|
11
|
-
@other_datetime = ::DateTime.new(2008, 3, 1, 18)
|
12
|
-
end
|
13
|
-
|
14
|
-
define_method "test localize DateTime: given the short format it uses it" do
|
15
|
-
# TODO should be Mrz, shouldn't it?
|
16
|
-
assert_equal '01. Mar 06:00', I18n.l(@datetime, :format => :short, :locale => :de)
|
17
|
-
end
|
18
|
-
|
19
|
-
define_method "test localize DateTime: given the long format it uses it" do
|
20
|
-
assert_equal '01. März 2008 06:00', I18n.l(@datetime, :format => :long, :locale => :de)
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method "test localize DateTime: given the default format it uses it" do
|
24
|
-
# TODO should be Mrz, shouldn't it?
|
25
|
-
assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de)
|
26
|
-
end
|
27
|
-
|
28
|
-
define_method "test localize DateTime: given a day name format it returns the correct day name" do
|
29
|
-
assert_equal 'Samstag', I18n.l(@datetime, :format => '%A', :locale => :de)
|
30
|
-
end
|
31
|
-
|
32
|
-
define_method "test localize DateTime: given an abbreviated day name format it returns the correct abbreviated day name" do
|
33
|
-
assert_equal 'Sa', I18n.l(@datetime, :format => '%a', :locale => :de)
|
34
|
-
end
|
35
|
-
|
36
|
-
define_method "test localize DateTime: given a month name format it returns the correct month name" do
|
37
|
-
assert_equal 'März', I18n.l(@datetime, :format => '%B', :locale => :de)
|
38
|
-
end
|
39
|
-
|
40
|
-
define_method "test localize DateTime: given an abbreviated month name format it returns the correct abbreviated month name" do
|
41
|
-
# TODO should be Mrz, shouldn't it?
|
42
|
-
assert_equal 'Mar', I18n.l(@datetime, :format => '%b', :locale => :de)
|
43
|
-
end
|
44
|
-
|
45
|
-
define_method "test localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do
|
46
|
-
assert_equal 'am', I18n.l(@datetime, :format => '%p', :locale => :de)
|
47
|
-
assert_equal 'pm', I18n.l(@other_datetime, :format => '%p', :locale => :de)
|
48
|
-
end
|
49
|
-
|
50
|
-
define_method "test localize Date: given a format that resolves to a Proc it calls the Proc with the object" do
|
51
|
-
if can_store_procs?
|
52
|
-
assert_equal '[Sat, 01 Mar 2008 06:00:00 +0000, {}]', I18n.l(@datetime, :format => :proc, :locale => :de)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# TODO fails, but something along these lines probably should pass
|
57
|
-
# define_method "test localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
58
|
-
# assert_equal '1ter März 2008, 06:00 Uhr', I18n.l(@datetime, :long_ordinalized)
|
59
|
-
# end
|
60
|
-
|
61
|
-
define_method "test localize DateTime: given an unknown format it does not fail" do
|
62
|
-
assert_nothing_raised { I18n.l(@datetime, :format => '%x') }
|
63
|
-
end
|
64
|
-
|
65
|
-
protected
|
66
|
-
|
67
|
-
def setup_datetime_translations
|
68
|
-
# time translations might have been set up in Tests::Api::Localization::Time
|
69
|
-
I18n.t(:'time.formats.default', :locale => :de, :raise => true)
|
70
|
-
rescue
|
71
|
-
store_translations :de, {
|
72
|
-
:time => {
|
73
|
-
:formats => {
|
74
|
-
:default => "%a, %d. %b %Y %H:%M:%S %z",
|
75
|
-
:short => "%d. %b %H:%M",
|
76
|
-
:long => "%d. %B %Y %H:%M",
|
77
|
-
:long_ordinalized => lambda { |date, options|
|
78
|
-
tz = " (#{options[:timezone]})" if options[:timezone]
|
79
|
-
"#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
|
80
|
-
}
|
81
|
-
},
|
82
|
-
:am => 'am',
|
83
|
-
:pm => 'pm'
|
84
|
-
}
|
85
|
-
}
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Localization
|
6
|
-
module Procs
|
7
|
-
define_method "test localize: using day names from lambdas" do
|
8
|
-
setup_time_proc_translations
|
9
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
10
|
-
assert_match /Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru)
|
11
|
-
assert_match /суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru)
|
12
|
-
end
|
13
|
-
|
14
|
-
define_method "test localize: using month names from lambdas" do
|
15
|
-
setup_time_proc_translations
|
16
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
17
|
-
assert_match /марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru)
|
18
|
-
assert_match /Март /, I18n.l(time, :format => "%B %Y", :locale => :ru)
|
19
|
-
end
|
20
|
-
|
21
|
-
define_method "test localize: using abbreviated day names from lambdas" do
|
22
|
-
setup_time_proc_translations
|
23
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
24
|
-
assert_match /марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru)
|
25
|
-
assert_match /март /, I18n.l(time, :format => "%b %Y", :locale => :ru)
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
|
30
|
-
def setup_time_proc_translations
|
31
|
-
store_translations :ru, {
|
32
|
-
:date => {
|
33
|
-
:'day_names' => lambda { |key, options|
|
34
|
-
(options[:format] =~ /^%A/) ?
|
35
|
-
%w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
|
36
|
-
%w(воскресенье понедельник вторник среда четверг пятница суббота)
|
37
|
-
},
|
38
|
-
:'month_names' => lambda { |key, options|
|
39
|
-
(options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
|
40
|
-
%w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
|
41
|
-
%w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
|
42
|
-
},
|
43
|
-
:'abbr_month_names' => lambda { |key, options|
|
44
|
-
(options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
|
45
|
-
%w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
|
46
|
-
%w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
|
47
|
-
},
|
48
|
-
}
|
49
|
-
}
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Localization
|
6
|
-
module Time
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
setup_time_translations
|
10
|
-
@time = ::Time.parse('2008-03-01 6:00 UTC')
|
11
|
-
@other_time = ::Time.parse('2008-03-01 18:00 UTC')
|
12
|
-
end
|
13
|
-
|
14
|
-
define_method "test localize Time: given the short format it uses it" do
|
15
|
-
# TODO should be Mrz, shouldn't it?
|
16
|
-
assert_equal '01. Mar 06:00', I18n.l(@time, :format => :short, :locale => :de)
|
17
|
-
end
|
18
|
-
|
19
|
-
define_method "test localize Time: given the long format it uses it" do
|
20
|
-
assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de)
|
21
|
-
end
|
22
|
-
|
23
|
-
# TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
|
24
|
-
# def test_localize_given_the_default_format_it_uses_it
|
25
|
-
# assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de)
|
26
|
-
# end
|
27
|
-
|
28
|
-
define_method "test localize Time: given a day name format it returns the correct day name" do
|
29
|
-
assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de)
|
30
|
-
end
|
31
|
-
|
32
|
-
define_method "test localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do
|
33
|
-
assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de)
|
34
|
-
end
|
35
|
-
|
36
|
-
define_method "test localize Time: given a month name format it returns the correct month name" do
|
37
|
-
assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de)
|
38
|
-
end
|
39
|
-
|
40
|
-
define_method "test localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do
|
41
|
-
# TODO should be Mrz, shouldn't it?
|
42
|
-
assert_equal 'Mar', I18n.l(@time, :format => '%b', :locale => :de)
|
43
|
-
end
|
44
|
-
|
45
|
-
define_method "test localize Time: given a meridian indicator format it returns the correct meridian indicator" do
|
46
|
-
assert_equal 'am', I18n.l(@time, :format => '%p', :locale => :de)
|
47
|
-
assert_equal 'pm', I18n.l(@other_time, :format => '%p', :locale => :de)
|
48
|
-
end
|
49
|
-
|
50
|
-
define_method "test localize Time: given a format that resolves to a Proc it calls the Proc with the object" do
|
51
|
-
if can_store_procs?
|
52
|
-
assert_equal '[Sat, 01 Mar 2008 06:00:00 +0000, {}]', I18n.l(@datetime, :format => :proc, :locale => :de)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# TODO fails, but something along these lines probably should pass
|
57
|
-
# define_method "test localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
58
|
-
# assert_equal '[Sat Mar 01 06:00:00 UTC 2008, {:foo=>"foo"}]', I18n.l(@time, :format => :proc, :foo => 'foo', :locale => :de)
|
59
|
-
# end
|
60
|
-
|
61
|
-
define_method "test localize Time: given an unknown format it does not fail" do
|
62
|
-
assert_nothing_raised { I18n.l(@time, :format => '%x') }
|
63
|
-
end
|
64
|
-
|
65
|
-
protected
|
66
|
-
|
67
|
-
def setup_time_translations
|
68
|
-
store_translations :de, {
|
69
|
-
:time => {
|
70
|
-
:formats => {
|
71
|
-
:default => "%a, %d. %b %Y %H:%M:%S %z",
|
72
|
-
:short => "%d. %b %H:%M",
|
73
|
-
:long => "%d. %B %Y %H:%M",
|
74
|
-
:proc => lambda { |*args| args.inspect }
|
75
|
-
},
|
76
|
-
:am => 'am',
|
77
|
-
:pm => 'pm'
|
78
|
-
}
|
79
|
-
}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Lookup
|
6
|
-
def setup
|
7
|
-
super
|
8
|
-
store_translations(:foo => { :bar => 'bar', :baz => 'baz' }, :bla => false)
|
9
|
-
end
|
10
|
-
|
11
|
-
define_method "test lookup: given a nested key it looks up the nested hash value" do
|
12
|
-
assert_equal 'bar', I18n.t(:'foo.bar')
|
13
|
-
end
|
14
|
-
|
15
|
-
define_method "test make sure we can store a native false value as well" do
|
16
|
-
assert_equal false, I18n.t(:bla)
|
17
|
-
end
|
18
|
-
|
19
|
-
define_method "test lookup: given a missing key, no default and no raise option it returns an error message" do
|
20
|
-
assert_equal "translation missing: en, missing", I18n.t(:missing)
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method "test lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do
|
24
|
-
assert_raises(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
25
|
-
end
|
26
|
-
|
27
|
-
define_method "test lookup: given an array of keys it translates all of them" do
|
28
|
-
assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo])
|
29
|
-
end
|
30
|
-
|
31
|
-
define_method "test lookup: using a custom scope separator" do
|
32
|
-
# data must have been stored using the custom separator when using the ActiveRecord backend
|
33
|
-
I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
|
34
|
-
assert_equal 'bar', I18n.t('foo|bar', :separator => '|')
|
35
|
-
end
|
36
|
-
|
37
|
-
# In fact it probably *should* fail but Rails currently relies on using the default locale instead.
|
38
|
-
# So we'll stick to this for now until we get it fixed in Rails.
|
39
|
-
define_method "test lookup: given nil as a locale it does not raise but use the default locale" do
|
40
|
-
# assert_raises(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) }
|
41
|
-
assert_nothing_raised { I18n.t(:bar, :locale => nil) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Pluralization
|
6
|
-
define_method "test pluralization: given 0 it returns the :zero translation if it is defined" do
|
7
|
-
assert_equal 'zero', I18n.t(:default => { :zero => 'zero' }, :count => 0)
|
8
|
-
end
|
9
|
-
|
10
|
-
define_method "test pluralization: given 0 it returns the :other translation if :zero is not defined" do
|
11
|
-
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 0)
|
12
|
-
end
|
13
|
-
|
14
|
-
define_method "test pluralization: given 1 it returns the singular translation" do
|
15
|
-
assert_equal 'bar', I18n.t(:default => { :one => 'bar' }, :count => 1)
|
16
|
-
end
|
17
|
-
|
18
|
-
define_method "test pluralization: given 2 it returns the :other translation" do
|
19
|
-
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 2)
|
20
|
-
end
|
21
|
-
|
22
|
-
define_method "test pluralization: given 3 it returns the :other translation" do
|
23
|
-
assert_equal 'bars', I18n.t(:default => { :other => 'bars' }, :count => 3)
|
24
|
-
end
|
25
|
-
|
26
|
-
define_method "test pluralization: given nil it returns the whole entry" do
|
27
|
-
assert_equal({ :one => 'bar' }, I18n.t(:default => { :one => 'bar' }, :count => nil))
|
28
|
-
end
|
29
|
-
|
30
|
-
define_method "test pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do
|
31
|
-
assert_raises(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Procs
|
6
|
-
define_method "test lookup: given a translation is a proc it calls the proc with the key and interpolation values" do
|
7
|
-
store_translations(:a_lambda => lambda { |*args| args.inspect })
|
8
|
-
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
|
9
|
-
end
|
10
|
-
|
11
|
-
define_method "test defaults: given a default is a Proc it calls it with the key and interpolation values" do
|
12
|
-
proc = lambda { |*args| args.inspect }
|
13
|
-
assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "test defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do
|
17
|
-
store_translations(:a_lambda => lambda { |*args| args.inspect })
|
18
|
-
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo')
|
19
|
-
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo')
|
20
|
-
end
|
21
|
-
|
22
|
-
define_method "test interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do
|
23
|
-
proc = lambda { |*args| args.inspect }
|
24
|
-
assert_match %r(\[\{:foo=>#<Proc.*>\}\]), I18n.t(nil, :default => '{{foo}}', :foo => proc)
|
25
|
-
end
|
26
|
-
|
27
|
-
define_method "test interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do
|
28
|
-
proc = lambda { |*args| "{{foo}}: " + args.inspect }
|
29
|
-
assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
30
|
-
end
|
31
|
-
|
32
|
-
define_method "test pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do
|
33
|
-
proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } }
|
34
|
-
assert_equal 'zero', I18n.t(:default => proc, :count => 0)
|
35
|
-
assert_equal 'one', I18n.t(:default => proc, :count => 1)
|
36
|
-
assert_equal 'other', I18n.t(:default => proc, :count => 2)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|