i18n 0.3.6 → 0.3.7
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.
- data/lib/i18n.rb +29 -4
- data/lib/i18n/backend/active_record/translation.rb +6 -4
- data/lib/i18n/backend/base.rb +1 -1
- data/lib/i18n/locale/fallbacks.rb +4 -4
- data/lib/i18n/version.rb +1 -1
- metadata +16 -116
- data/CHANGELOG.textile +0 -76
- data/MIT-LICENSE +0 -20
- data/README.textile +0 -104
- data/Rakefile +0 -29
- data/test/all.rb +0 -8
- data/test/api.rb +0 -18
- data/test/api/active_record_test.rb +0 -30
- data/test/api/all_features_test.rb +0 -59
- data/test/api/cascade_test.rb +0 -32
- data/test/api/chain_test.rb +0 -27
- data/test/api/fallbacks_test.rb +0 -34
- data/test/api/fast_test.rb +0 -32
- data/test/api/pluralization_test.rb +0 -34
- data/test/api/simple_test.rb +0 -23
- data/test/api/tests/basics.rb +0 -15
- data/test/api/tests/defaults.rb +0 -40
- data/test/api/tests/interpolation.rb +0 -92
- data/test/api/tests/link.rb +0 -56
- data/test/api/tests/localization/date.rb +0 -96
- data/test/api/tests/localization/date_time.rb +0 -93
- data/test/api/tests/localization/procs.rb +0 -60
- data/test/api/tests/localization/time.rb +0 -88
- data/test/api/tests/lookup.rb +0 -62
- data/test/api/tests/pluralization.rb +0 -35
- data/test/api/tests/procs.rb +0 -55
- data/test/backend/active_record/missing_test.rb +0 -51
- data/test/backend/active_record_test.rb +0 -57
- data/test/backend/cache_test.rb +0 -71
- data/test/backend/cascade_test.rb +0 -73
- data/test/backend/chain_test.rb +0 -63
- data/test/backend/cldr_test.rb +0 -151
- data/test/backend/exceptions_test.rb +0 -25
- data/test/backend/fallbacks_test.rb +0 -107
- data/test/backend/fast_test.rb +0 -50
- data/test/backend/helpers_test.rb +0 -27
- data/test/backend/interpolation_compiler_test.rb +0 -108
- data/test/backend/metadata_test.rb +0 -66
- data/test/backend/pluralization_test.rb +0 -47
- data/test/backend/simple_test.rb +0 -77
- data/test/core_ext/string/interpolate_test.rb +0 -99
- data/test/gettext/api_test.rb +0 -207
- data/test/gettext/backend_test.rb +0 -91
- data/test/i18n_exceptions_test.rb +0 -97
- data/test/i18n_load_path_test.rb +0 -23
- data/test/i18n_test.rb +0 -207
- data/test/locale/fallbacks_test.rb +0 -126
- data/test/locale/tag/rfc4646_test.rb +0 -143
- data/test/locale/tag/simple_test.rb +0 -33
- data/test/test_data/locales/cldr/de/calendars.yml +0 -152
- data/test/test_data/locales/cldr/de/currencies.yml +0 -8
- data/test/test_data/locales/cldr/de/numbers.yml +0 -31
- data/test/test_data/locales/de.po +0 -72
- data/test/test_data/locales/en.rb +0 -3
- data/test/test_data/locales/en.yml +0 -3
- data/test/test_data/locales/plurals.rb +0 -113
- data/test/test_helper.rb +0 -116
data/test/api/tests/link.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Tests
|
4
|
-
module Api
|
5
|
-
module Link
|
6
|
-
define_method "test linked lookup: if a key resolves to a symbol it looks up the symbol" do
|
7
|
-
I18n.backend.store_translations 'en', {
|
8
|
-
:link => :linked,
|
9
|
-
:linked => 'linked'
|
10
|
-
}
|
11
|
-
assert_equal 'linked', I18n.backend.translate('en', :link)
|
12
|
-
end
|
13
|
-
|
14
|
-
define_method "test linked lookup: if a key resolves to a dot-separated symbol it looks up the symbol" do
|
15
|
-
I18n.backend.store_translations 'en', {
|
16
|
-
:link => :"foo.linked",
|
17
|
-
:foo => { :linked => 'linked' }
|
18
|
-
}
|
19
|
-
assert_equal('linked', I18n.backend.translate('en', :link))
|
20
|
-
end
|
21
|
-
|
22
|
-
define_method "test linked lookup: if a dot-separated key resolves to a symbol it looks up the symbol" do
|
23
|
-
I18n.backend.store_translations 'en', {
|
24
|
-
:foo => { :link => :linked },
|
25
|
-
:linked => 'linked'
|
26
|
-
}
|
27
|
-
assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
|
28
|
-
end
|
29
|
-
|
30
|
-
define_method "test linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
|
31
|
-
I18n.backend.store_translations 'en', {
|
32
|
-
:foo => { :link => :"bar.linked" },
|
33
|
-
:bar => { :linked => 'linked' }
|
34
|
-
}
|
35
|
-
assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
|
36
|
-
end
|
37
|
-
|
38
|
-
define_method "test linked lookup: links refer to a key relative to the given scope" do
|
39
|
-
I18n.backend.store_translations 'en', {
|
40
|
-
:foo => { :link => :linked, :linked => 'linked in foo' },
|
41
|
-
:linked => 'linked absolutely'
|
42
|
-
}
|
43
|
-
assert_equal 'linked in foo', I18n.backend.translate('en', :link, :scope => :foo)
|
44
|
-
end
|
45
|
-
|
46
|
-
define_method "test linked lookup: a link can resolve to a namespace in the middle of a dot-separated key" do
|
47
|
-
I18n.backend.store_translations 'en', {
|
48
|
-
:activemodel => { :errors => { :messages => { :blank => "can't be blank" } } },
|
49
|
-
:activerecord => { :errors => { :messages => :"activemodel.errors.messages" } }
|
50
|
-
}
|
51
|
-
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
|
52
|
-
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,96 +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
|
-
if can_store_procs?
|
45
|
-
assert_equal '[:"date.formats.proc", {}]', I18n.l(@date, :format => :proc, :locale => :de)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# TODO fails, but something along these lines probably should pass
|
50
|
-
# define_method "test localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
51
|
-
# assert_equal '[Sat Mar 01 06:00:00 UTC 2008, {:foo=>"foo"}]', I18n.l(@time, :format => :proc, :foo => 'foo', :locale => :de)
|
52
|
-
# end
|
53
|
-
|
54
|
-
define_method "test localize Date: given an unknown format it does not fail" do
|
55
|
-
assert_nothing_raised { I18n.l(@date, :format => '%x') }
|
56
|
-
end
|
57
|
-
|
58
|
-
define_method "test localize Date: given nil it raises I18n::ArgumentError" do
|
59
|
-
assert_raise(I18n::ArgumentError) { I18n.l(nil) }
|
60
|
-
end
|
61
|
-
|
62
|
-
define_method "test localize Date: given a plain Object it raises I18n::ArgumentError" do
|
63
|
-
assert_raise(I18n::ArgumentError) { I18n.l(Object.new) }
|
64
|
-
end
|
65
|
-
|
66
|
-
define_method "test localize Date: given a format is missing it raises I18n::MissingTranslationData" do
|
67
|
-
assert_raise(I18n::MissingTranslationData) { I18n.l(@date, :format => :missing) }
|
68
|
-
end
|
69
|
-
|
70
|
-
define_method "test localize Date: it does not alter the format string" do
|
71
|
-
assert_equal '01. Februar 2009', I18n.l(::Date.parse('2009-02-01'), :format => :long, :locale => :de)
|
72
|
-
assert_equal '01. Oktober 2009', I18n.l(::Date.parse('2009-10-01'), :format => :long, :locale => :de)
|
73
|
-
end
|
74
|
-
|
75
|
-
protected
|
76
|
-
|
77
|
-
def setup_date_translations
|
78
|
-
store_translations :de, {
|
79
|
-
:date => {
|
80
|
-
:formats => {
|
81
|
-
:default => "%d.%m.%Y",
|
82
|
-
:short => "%d. %b",
|
83
|
-
:long => "%d. %B %Y",
|
84
|
-
:proc => lambda { |*args| args.inspect }
|
85
|
-
},
|
86
|
-
:day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
|
87
|
-
:abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
|
88
|
-
:month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
|
89
|
-
:abbr_month_names => %w(Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
|
90
|
-
}
|
91
|
-
}
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,93 +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 DateTime: given a format that resolves to a Proc it calls the Proc with the object" do
|
51
|
-
if can_store_procs?
|
52
|
-
assert_equal '[:"time.formats.proc", {}]', 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
|
-
define_method "test localize DateTime: given a format is missing it raises I18n::MissingTranslationData" do
|
66
|
-
assert_raise(I18n::MissingTranslationData) { I18n.l(@datetime, :format => :missing) }
|
67
|
-
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
|
71
|
-
def setup_datetime_translations
|
72
|
-
# time translations might have been set up in Tests::Api::Localization::Time
|
73
|
-
store_translations :de, {
|
74
|
-
:time => {
|
75
|
-
:formats => {
|
76
|
-
:default => "%a, %d. %b %Y %H:%M:%S %z",
|
77
|
-
:short => "%d. %b %H:%M",
|
78
|
-
:long => "%d. %B %Y %H:%M",
|
79
|
-
:long_ordinalized => lambda { |date, options|
|
80
|
-
tz = " (#{options[:timezone]})" if options[:timezone]
|
81
|
-
"#{date.day}ter %B %Y, %H:%M Uhr#{tz}"
|
82
|
-
},
|
83
|
-
:proc => lambda { |*args| args.inspect }
|
84
|
-
},
|
85
|
-
:am => 'am',
|
86
|
-
:pm => 'pm'
|
87
|
-
}
|
88
|
-
}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,60 +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
|
-
if can_store_procs?
|
9
|
-
setup_time_proc_translations
|
10
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
11
|
-
assert_match /Суббота/, I18n.l(time, :format => "%A, %d %B", :locale => :ru)
|
12
|
-
assert_match /суббота/, I18n.l(time, :format => "%d %B (%A)", :locale => :ru)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "test localize: using month names from lambdas" do
|
17
|
-
if can_store_procs?
|
18
|
-
setup_time_proc_translations
|
19
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
20
|
-
assert_match /марта/, I18n.l(time, :format => "%d %B %Y", :locale => :ru)
|
21
|
-
assert_match /Март /, I18n.l(time, :format => "%B %Y", :locale => :ru)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
define_method "test localize: using abbreviated day names from lambdas" do
|
26
|
-
if can_store_procs?
|
27
|
-
setup_time_proc_translations
|
28
|
-
time = ::Time.parse('2008-03-01 6:00 UTC')
|
29
|
-
assert_match /марта/, I18n.l(time, :format => "%d %b %Y", :locale => :ru)
|
30
|
-
assert_match /март /, I18n.l(time, :format => "%b %Y", :locale => :ru)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
protected
|
35
|
-
|
36
|
-
def setup_time_proc_translations
|
37
|
-
store_translations :ru, {
|
38
|
-
:date => {
|
39
|
-
:'day_names' => lambda { |key, options|
|
40
|
-
(options[:format] =~ /^%A/) ?
|
41
|
-
%w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
|
42
|
-
%w(воскресенье понедельник вторник среда четверг пятница суббота)
|
43
|
-
},
|
44
|
-
:'month_names' => lambda { |key, options|
|
45
|
-
(options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
|
46
|
-
%w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
|
47
|
-
%w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
|
48
|
-
},
|
49
|
-
:'abbr_month_names' => lambda { |key, options|
|
50
|
-
(options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
|
51
|
-
%w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
|
52
|
-
%w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
|
53
|
-
},
|
54
|
-
}
|
55
|
-
}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,88 +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 '[:"time.formats.proc", {}]', I18n.l(@time, :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
|
-
define_method "test localize Time: given a format is missing it raises I18n::MissingTranslationData" do
|
66
|
-
assert_raise(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) }
|
67
|
-
end
|
68
|
-
|
69
|
-
protected
|
70
|
-
|
71
|
-
def setup_time_translations
|
72
|
-
store_translations :de, {
|
73
|
-
:time => {
|
74
|
-
:formats => {
|
75
|
-
:default => "%a, %d. %b %Y %H:%M:%S %z",
|
76
|
-
:short => "%d. %b %H:%M",
|
77
|
-
:long => "%d. %B %Y %H:%M",
|
78
|
-
:proc => lambda { |*args| args.inspect }
|
79
|
-
},
|
80
|
-
:am => 'am',
|
81
|
-
:pm => 'pm'
|
82
|
-
}
|
83
|
-
}
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
data/test/api/tests/lookup.rb
DELETED
@@ -1,62 +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, :ble => %(a b c))
|
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_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
25
|
-
end
|
26
|
-
|
27
|
-
define_method "test lookup: does not raise an exception if no translation data is present for the given locale" do
|
28
|
-
assert_nothing_raised { I18n.t(:foo, :locale => :xx) }
|
29
|
-
end
|
30
|
-
|
31
|
-
define_method "test lookup: given an array of keys it translates all of them" do
|
32
|
-
assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo])
|
33
|
-
end
|
34
|
-
|
35
|
-
define_method "test lookup: using a custom scope separator" do
|
36
|
-
# data must have been stored using the custom separator when using the ActiveRecord backend
|
37
|
-
I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
|
38
|
-
assert_equal 'bar', I18n.t('foo|bar', :separator => '|')
|
39
|
-
end
|
40
|
-
|
41
|
-
# In fact it probably *should* fail but Rails currently relies on using the default locale instead.
|
42
|
-
# So we'll stick to this for now until we get it fixed in Rails.
|
43
|
-
define_method "test lookup: given nil as a locale it does not raise but use the default locale" do
|
44
|
-
# assert_raise(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) }
|
45
|
-
assert_nothing_raised { I18n.t(:bar, :locale => nil) }
|
46
|
-
end
|
47
|
-
|
48
|
-
define_method "test lookup: a resulting String is not frozen" do
|
49
|
-
I18n.t(:'foo.bar')
|
50
|
-
assert !I18n.t(:'foo.bar').frozen?
|
51
|
-
end
|
52
|
-
|
53
|
-
define_method "test lookup: a resulting Array is not frozen" do
|
54
|
-
assert !I18n.t(:'foo.bar').frozen?
|
55
|
-
end
|
56
|
-
|
57
|
-
define_method "test lookup: a resulting Hash is not frozen" do
|
58
|
-
assert !I18n.t(:'foo').frozen?
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|