i18n 0.9.5 → 1.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +70 -32
- data/lib/i18n.rb +95 -36
- data/lib/i18n/backend.rb +3 -0
- data/lib/i18n/backend/base.rb +53 -23
- data/lib/i18n/backend/cache.rb +10 -11
- data/lib/i18n/backend/cache_file.rb +36 -0
- data/lib/i18n/backend/cascade.rb +3 -1
- data/lib/i18n/backend/chain.rb +38 -5
- data/lib/i18n/backend/fallbacks.rb +25 -14
- data/lib/i18n/backend/flatten.rb +10 -5
- data/lib/i18n/backend/gettext.rb +4 -0
- data/lib/i18n/backend/interpolation_compiler.rb +3 -1
- data/lib/i18n/backend/key_value.rb +31 -2
- data/lib/i18n/backend/memoize.rb +10 -2
- data/lib/i18n/backend/metadata.rb +5 -3
- data/lib/i18n/backend/pluralization.rb +3 -1
- data/lib/i18n/backend/simple.rb +26 -10
- data/lib/i18n/backend/transliterator.rb +2 -0
- data/lib/i18n/config.rb +20 -2
- data/lib/i18n/core_ext/hash.rb +54 -24
- data/lib/i18n/exceptions.rb +23 -16
- data/lib/i18n/gettext.rb +2 -0
- data/lib/i18n/gettext/helpers.rb +4 -2
- data/lib/i18n/gettext/po_parser.rb +7 -7
- data/lib/i18n/interpolate/ruby.rb +6 -4
- data/lib/i18n/locale.rb +2 -0
- data/lib/i18n/locale/fallbacks.rb +9 -6
- data/lib/i18n/locale/tag/parents.rb +8 -6
- data/lib/i18n/locale/tag/simple.rb +1 -1
- data/lib/i18n/middleware.rb +2 -0
- data/lib/i18n/tests.rb +2 -0
- data/lib/i18n/tests/interpolation.rb +9 -4
- data/lib/i18n/tests/link.rb +11 -1
- data/lib/i18n/tests/localization/date.rb +29 -7
- data/lib/i18n/tests/localization/date_time.rb +27 -6
- data/lib/i18n/tests/localization/procs.rb +6 -5
- data/lib/i18n/tests/localization/time.rb +26 -4
- data/lib/i18n/tests/lookup.rb +2 -2
- data/lib/i18n/tests/procs.rb +5 -0
- data/lib/i18n/version.rb +3 -1
- metadata +14 -60
- data/gemfiles/Gemfile.rails-3.2.x +0 -10
- data/gemfiles/Gemfile.rails-4.0.x +0 -10
- data/gemfiles/Gemfile.rails-4.1.x +0 -10
- data/gemfiles/Gemfile.rails-4.2.x +0 -10
- data/gemfiles/Gemfile.rails-5.0.x +0 -10
- data/gemfiles/Gemfile.rails-5.1.x +0 -10
- data/gemfiles/Gemfile.rails-master +0 -10
- data/lib/i18n/core_ext/kernel/suppress_warnings.rb +0 -8
- data/lib/i18n/core_ext/string/interpolate.rb +0 -9
- data/test/api/all_features_test.rb +0 -58
- data/test/api/cascade_test.rb +0 -28
- data/test/api/chain_test.rb +0 -24
- data/test/api/fallbacks_test.rb +0 -30
- data/test/api/key_value_test.rb +0 -24
- data/test/api/memoize_test.rb +0 -56
- data/test/api/override_test.rb +0 -42
- data/test/api/pluralization_test.rb +0 -30
- data/test/api/simple_test.rb +0 -28
- data/test/backend/cache_test.rb +0 -109
- data/test/backend/cascade_test.rb +0 -86
- data/test/backend/chain_test.rb +0 -122
- data/test/backend/exceptions_test.rb +0 -36
- data/test/backend/fallbacks_test.rb +0 -219
- data/test/backend/interpolation_compiler_test.rb +0 -118
- data/test/backend/key_value_test.rb +0 -61
- data/test/backend/memoize_test.rb +0 -79
- data/test/backend/metadata_test.rb +0 -48
- data/test/backend/pluralization_test.rb +0 -45
- data/test/backend/simple_test.rb +0 -103
- data/test/backend/transliterator_test.rb +0 -84
- data/test/core_ext/hash_test.rb +0 -36
- data/test/gettext/api_test.rb +0 -214
- data/test/gettext/backend_test.rb +0 -92
- data/test/i18n/exceptions_test.rb +0 -117
- data/test/i18n/gettext_plural_keys_test.rb +0 -20
- data/test/i18n/interpolate_test.rb +0 -91
- data/test/i18n/load_path_test.rb +0 -34
- data/test/i18n/middleware_test.rb +0 -24
- data/test/i18n_test.rb +0 -462
- data/test/locale/fallbacks_test.rb +0 -133
- data/test/locale/tag/rfc4646_test.rb +0 -143
- data/test/locale/tag/simple_test.rb +0 -32
- data/test/run_all.rb +0 -20
- data/test/test_data/locales/de.po +0 -82
- data/test/test_data/locales/en.rb +0 -3
- data/test/test_data/locales/en.yml +0 -3
- data/test/test_data/locales/invalid/empty.yml +0 -0
- data/test/test_data/locales/invalid/syntax.yml +0 -4
- data/test/test_data/locales/plurals.rb +0 -113
- data/test/test_helper.rb +0 -61
@@ -3,18 +3,20 @@ module I18n
|
|
3
3
|
module Tag
|
4
4
|
module Parents
|
5
5
|
def parent
|
6
|
-
@parent ||=
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
@parent ||=
|
7
|
+
begin
|
8
|
+
segs = to_a
|
9
|
+
segs.compact!
|
10
|
+
segs.length > 1 ? self.class.tag(*segs[0..(segs.length - 2)].join('-')) : nil
|
11
|
+
end
|
10
12
|
end
|
11
13
|
|
12
14
|
def self_and_parents
|
13
|
-
@self_and_parents ||= [self]
|
15
|
+
@self_and_parents ||= [self].concat parents
|
14
16
|
end
|
15
17
|
|
16
18
|
def parents
|
17
|
-
@parents ||=
|
19
|
+
@parents ||= parent ? [parent].concat(parent.parents) : []
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/i18n/middleware.rb
CHANGED
data/lib/i18n/tests.rb
CHANGED
@@ -24,6 +24,10 @@ module I18n
|
|
24
24
|
assert_equal 'Hi David!', interpolate(:default => 'Hi %{name}!', :name => 'David')
|
25
25
|
end
|
26
26
|
|
27
|
+
test "interpolation: works with a pipe" do
|
28
|
+
assert_equal 'Hi david!', interpolate(:default => 'Hi %{name|lowercase}!', :'name|lowercase' => 'david')
|
29
|
+
end
|
30
|
+
|
27
31
|
test "interpolation: given a nil value it still interpolates it into the string" do
|
28
32
|
assert_equal 'Hi !', interpolate(:default => 'Hi %{name}!', :name => nil)
|
29
33
|
end
|
@@ -43,7 +47,7 @@ module I18n
|
|
43
47
|
end
|
44
48
|
|
45
49
|
test "interpolation: it does not raise I18n::MissingInterpolationArgument for escaped variables" do
|
46
|
-
assert_nothing_raised
|
50
|
+
assert_nothing_raised do
|
47
51
|
assert_equal 'Barr %{foo}', interpolate(:default => '%{bar} %%{foo}', :bar => 'Barr')
|
48
52
|
end
|
49
53
|
end
|
@@ -104,9 +108,10 @@ module I18n
|
|
104
108
|
end
|
105
109
|
|
106
110
|
test "interpolation: given a translations containing a reserved key it raises I18n::ReservedInterpolationKey" do
|
107
|
-
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{
|
108
|
-
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{
|
109
|
-
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:default => '%{separator}'
|
111
|
+
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{exception_handler}') }
|
112
|
+
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{default}') }
|
113
|
+
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{separator}') }
|
114
|
+
assert_raise(I18n::ReservedInterpolationKey) { interpolate(:foo => :bar, :default => '%{scope}') }
|
110
115
|
end
|
111
116
|
|
112
117
|
test "interpolation: deep interpolation for default string" do
|
data/lib/i18n/tests/link.rb
CHANGED
@@ -26,7 +26,7 @@ module I18n
|
|
26
26
|
}
|
27
27
|
assert_equal('linked', I18n.backend.translate('en', :'foo.link'))
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
test "linked lookup: if a dot-separated key resolves to a dot-separated symbol it looks up the symbol" do
|
31
31
|
I18n.backend.store_translations 'en', {
|
32
32
|
:foo => { :link => :"bar.linked" },
|
@@ -51,6 +51,16 @@ module I18n
|
|
51
51
|
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
|
52
52
|
assert_equal "can't be blank", I18n.t(:"activerecord.errors.messages.blank")
|
53
53
|
end
|
54
|
+
|
55
|
+
test "linked lookup: a link can resolve with option :count" do
|
56
|
+
I18n.backend.store_translations 'en', {
|
57
|
+
:counter => :counted,
|
58
|
+
:counted => { :foo => { :one => "one", :other => "other" }, :bar => "bar" }
|
59
|
+
}
|
60
|
+
assert_equal "one", I18n.t(:'counter.foo', count: 1)
|
61
|
+
assert_equal "other", I18n.t(:'counter.foo', count: 2)
|
62
|
+
assert_equal "bar", I18n.t(:'counter.bar', count: 3)
|
63
|
+
end
|
54
64
|
end
|
55
65
|
end
|
56
66
|
end
|
@@ -11,8 +11,7 @@ module I18n
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test "localize Date: given the short format it uses it" do
|
14
|
-
|
15
|
-
assert_equal '01. Mar', I18n.l(@date, :format => :short, :locale => :de)
|
14
|
+
assert_equal '01. Mär', I18n.l(@date, :format => :short, :locale => :de)
|
16
15
|
end
|
17
16
|
|
18
17
|
test "localize Date: given the long format it uses it" do
|
@@ -27,17 +26,40 @@ module I18n
|
|
27
26
|
assert_equal 'Samstag', I18n.l(@date, :format => '%A', :locale => :de)
|
28
27
|
end
|
29
28
|
|
29
|
+
test "localize Date: given a uppercased day name format it returns the correct day name in upcase" do
|
30
|
+
assert_equal 'samstag'.upcase, I18n.l(@date, :format => '%^A', :locale => :de)
|
31
|
+
end
|
32
|
+
|
30
33
|
test "localize Date: given an abbreviated day name format it returns the correct abbreviated day name" do
|
31
34
|
assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de)
|
32
35
|
end
|
33
36
|
|
37
|
+
test "localize Date: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do
|
38
|
+
assert_equal 'sa'.upcase, I18n.l(@date, :format => '%^a', :locale => :de)
|
39
|
+
end
|
40
|
+
|
34
41
|
test "localize Date: given a month name format it returns the correct month name" do
|
35
42
|
assert_equal 'März', I18n.l(@date, :format => '%B', :locale => :de)
|
36
43
|
end
|
37
44
|
|
45
|
+
test "localize Date: given a uppercased month name format it returns the correct month name in upcase" do
|
46
|
+
assert_equal 'märz'.upcase, I18n.l(@date, :format => '%^B', :locale => :de)
|
47
|
+
end
|
48
|
+
|
38
49
|
test "localize Date: given an abbreviated month name format it returns the correct abbreviated month name" do
|
39
|
-
|
40
|
-
|
50
|
+
assert_equal 'Mär', I18n.l(@date, :format => '%b', :locale => :de)
|
51
|
+
end
|
52
|
+
|
53
|
+
test "localize Date: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do
|
54
|
+
assert_equal 'mär'.upcase, I18n.l(@date, :format => '%^b', :locale => :de)
|
55
|
+
end
|
56
|
+
|
57
|
+
test "localize Date: given a date format with the month name upcased it returns the correct value" do
|
58
|
+
assert_equal '1. FEBRUAR 2008', I18n.l(::Date.new(2008, 2, 1), :format => "%-d. %^B %Y", :locale => :de)
|
59
|
+
end
|
60
|
+
|
61
|
+
test "localize Date: given missing translations it returns the correct error message" do
|
62
|
+
assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@date, :format => '%b', :locale => :fr)
|
41
63
|
end
|
42
64
|
|
43
65
|
test "localize Date: given an unknown format it does not fail" do
|
@@ -46,9 +68,9 @@ module I18n
|
|
46
68
|
|
47
69
|
test "localize Date: does not modify the options hash" do
|
48
70
|
options = { :format => '%b', :locale => :de }
|
49
|
-
assert_equal '
|
71
|
+
assert_equal 'Mär', I18n.l(@date, **options)
|
50
72
|
assert_equal({ :format => '%b', :locale => :de }, options)
|
51
|
-
assert_nothing_raised { I18n.l(@date, options.freeze) }
|
73
|
+
assert_nothing_raised { I18n.l(@date, **options.freeze) }
|
52
74
|
end
|
53
75
|
|
54
76
|
test "localize Date: given nil with default value it returns default" do
|
@@ -85,7 +107,7 @@ module I18n
|
|
85
107
|
:day_names => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
|
86
108
|
:abbr_day_names => %w(So Mo Di Mi Do Fr Sa),
|
87
109
|
:month_names => %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember).unshift(nil),
|
88
|
-
:abbr_month_names => %w(Jan Feb
|
110
|
+
:abbr_month_names => %w(Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez).unshift(nil)
|
89
111
|
}
|
90
112
|
}
|
91
113
|
end
|
@@ -12,8 +12,7 @@ module I18n
|
|
12
12
|
end
|
13
13
|
|
14
14
|
test "localize DateTime: given the short format it uses it" do
|
15
|
-
|
16
|
-
assert_equal '01. Mar 06:00', I18n.l(@datetime, :format => :short, :locale => :de)
|
15
|
+
assert_equal '01. Mär 06:00', I18n.l(@datetime, :format => :short, :locale => :de)
|
17
16
|
end
|
18
17
|
|
19
18
|
test "localize DateTime: given the long format it uses it" do
|
@@ -21,25 +20,47 @@ module I18n
|
|
21
20
|
end
|
22
21
|
|
23
22
|
test "localize DateTime: given the default format it uses it" do
|
24
|
-
|
25
|
-
assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de)
|
23
|
+
assert_equal 'Sa, 01. Mär 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de)
|
26
24
|
end
|
27
25
|
|
28
26
|
test "localize DateTime: given a day name format it returns the correct day name" do
|
29
27
|
assert_equal 'Samstag', I18n.l(@datetime, :format => '%A', :locale => :de)
|
30
28
|
end
|
31
29
|
|
30
|
+
test "localize DateTime: given a uppercased day name format it returns the correct day name in upcase" do
|
31
|
+
assert_equal 'samstag'.upcase, I18n.l(@datetime, :format => '%^A', :locale => :de)
|
32
|
+
end
|
33
|
+
|
32
34
|
test "localize DateTime: given an abbreviated day name format it returns the correct abbreviated day name" do
|
33
35
|
assert_equal 'Sa', I18n.l(@datetime, :format => '%a', :locale => :de)
|
34
36
|
end
|
35
37
|
|
38
|
+
test "localize DateTime: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do
|
39
|
+
assert_equal 'sa'.upcase, I18n.l(@datetime, :format => '%^a', :locale => :de)
|
40
|
+
end
|
41
|
+
|
36
42
|
test "localize DateTime: given a month name format it returns the correct month name" do
|
37
43
|
assert_equal 'März', I18n.l(@datetime, :format => '%B', :locale => :de)
|
38
44
|
end
|
39
45
|
|
46
|
+
test "localize DateTime: given a uppercased month name format it returns the correct month name in upcase" do
|
47
|
+
assert_equal 'märz'.upcase, I18n.l(@datetime, :format => '%^B', :locale => :de)
|
48
|
+
end
|
49
|
+
|
40
50
|
test "localize DateTime: given an abbreviated month name format it returns the correct abbreviated month name" do
|
41
|
-
|
42
|
-
|
51
|
+
assert_equal 'Mär', I18n.l(@datetime, :format => '%b', :locale => :de)
|
52
|
+
end
|
53
|
+
|
54
|
+
test "localize DateTime: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do
|
55
|
+
assert_equal 'mär'.upcase, I18n.l(@datetime, :format => '%^b', :locale => :de)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "localize DateTime: given a date format with the month name upcased it returns the correct value" do
|
59
|
+
assert_equal '1. FEBRUAR 2008', I18n.l(::DateTime.new(2008, 2, 1, 6), :format => "%-d. %^B %Y", :locale => :de)
|
60
|
+
end
|
61
|
+
|
62
|
+
test "localize DateTime: given missing translations it returns the correct error message" do
|
63
|
+
assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@datetime, :format => '%b', :locale => :fr)
|
43
64
|
end
|
44
65
|
|
45
66
|
test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do
|
@@ -52,19 +52,20 @@ module I18n
|
|
52
52
|
test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do
|
53
53
|
setup_time_proc_translations
|
54
54
|
time = ::Time.utc(2008, 3, 1, 6, 0)
|
55
|
-
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, {}
|
55
|
+
assert_equal I18n::Tests::Localization::Procs.inspect_args([time], {}), I18n.l(time, :format => :proc, :locale => :ru)
|
56
56
|
end
|
57
57
|
|
58
58
|
test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
59
59
|
setup_time_proc_translations
|
60
60
|
time = ::Time.utc(2008, 3, 1, 6, 0)
|
61
61
|
options = { :foo => 'foo' }
|
62
|
-
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, options
|
62
|
+
assert_equal I18n::Tests::Localization::Procs.inspect_args([time], options), I18n.l(time, **options.merge(:format => :proc, :locale => :ru))
|
63
63
|
end
|
64
64
|
|
65
65
|
protected
|
66
66
|
|
67
|
-
def self.inspect_args(args)
|
67
|
+
def self.inspect_args(args, kwargs)
|
68
|
+
args << kwargs
|
68
69
|
args = args.map do |arg|
|
69
70
|
case arg
|
70
71
|
when ::Time, ::DateTime
|
@@ -85,12 +86,12 @@ module I18n
|
|
85
86
|
I18n.backend.store_translations :ru, {
|
86
87
|
:time => {
|
87
88
|
:formats => {
|
88
|
-
:proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) }
|
89
|
+
:proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) }
|
89
90
|
}
|
90
91
|
},
|
91
92
|
:date => {
|
92
93
|
:formats => {
|
93
|
-
:proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) }
|
94
|
+
:proc => lambda { |*args, **kwargs| I18n::Tests::Localization::Procs.inspect_args(args, kwargs) }
|
94
95
|
},
|
95
96
|
:'day_names' => lambda { |key, options|
|
96
97
|
(options[:format] =~ /^%A/) ?
|
@@ -12,8 +12,7 @@ module I18n
|
|
12
12
|
end
|
13
13
|
|
14
14
|
test "localize Time: given the short format it uses it" do
|
15
|
-
|
16
|
-
assert_equal '01. Mar 06:00', I18n.l(@time, :format => :short, :locale => :de)
|
15
|
+
assert_equal '01. Mär 06:00', I18n.l(@time, :format => :short, :locale => :de)
|
17
16
|
end
|
18
17
|
|
19
18
|
test "localize Time: given the long format it uses it" do
|
@@ -29,17 +28,40 @@ module I18n
|
|
29
28
|
assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de)
|
30
29
|
end
|
31
30
|
|
31
|
+
test "localize Time: given a uppercased day name format it returns the correct day name in upcase" do
|
32
|
+
assert_equal 'samstag'.upcase, I18n.l(@time, :format => '%^A', :locale => :de)
|
33
|
+
end
|
34
|
+
|
32
35
|
test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do
|
33
36
|
assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de)
|
34
37
|
end
|
35
38
|
|
39
|
+
test "localize Time: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do
|
40
|
+
assert_equal 'sa'.upcase, I18n.l(@time, :format => '%^a', :locale => :de)
|
41
|
+
end
|
42
|
+
|
36
43
|
test "localize Time: given a month name format it returns the correct month name" do
|
37
44
|
assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de)
|
38
45
|
end
|
39
46
|
|
47
|
+
test "localize Time: given a uppercased month name format it returns the correct month name in upcase" do
|
48
|
+
assert_equal 'märz'.upcase, I18n.l(@time, :format => '%^B', :locale => :de)
|
49
|
+
end
|
50
|
+
|
40
51
|
test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do
|
41
|
-
|
42
|
-
|
52
|
+
assert_equal 'Mär', I18n.l(@time, :format => '%b', :locale => :de)
|
53
|
+
end
|
54
|
+
|
55
|
+
test "localize Time: given an abbreviated and uppercased month name format it returns the correct abbreviated month name in upcase" do
|
56
|
+
assert_equal 'mär'.upcase, I18n.l(@time, :format => '%^b', :locale => :de)
|
57
|
+
end
|
58
|
+
|
59
|
+
test "localize Time: given a date format with the month name upcased it returns the correct value" do
|
60
|
+
assert_equal '1. FEBRUAR 2008', I18n.l(::Time.utc(2008, 2, 1, 6, 0), :format => "%-d. %^B %Y", :locale => :de)
|
61
|
+
end
|
62
|
+
|
63
|
+
test "localize Time: given missing translations it returns the correct error message" do
|
64
|
+
assert_equal 'translation missing: fr.date.abbr_month_names', I18n.l(@time, :format => '%b', :locale => :fr)
|
43
65
|
end
|
44
66
|
|
45
67
|
test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
|
data/lib/i18n/tests/lookup.rb
CHANGED
@@ -43,9 +43,9 @@ module I18n
|
|
43
43
|
|
44
44
|
test "lookup: does not modify the options hash" do
|
45
45
|
options = {}
|
46
|
-
assert_equal "a", I18n.t(:string, options)
|
46
|
+
assert_equal "a", I18n.t(:string, **options)
|
47
47
|
assert_equal({}, options)
|
48
|
-
assert_nothing_raised { I18n.t(:string, options.freeze) }
|
48
|
+
assert_nothing_raised { I18n.t(:string, **options.freeze) }
|
49
49
|
end
|
50
50
|
|
51
51
|
test "lookup: given an array of keys it translates all of them" do
|
data/lib/i18n/tests/procs.rb
CHANGED
@@ -8,6 +8,11 @@ module I18n
|
|
8
8
|
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
|
9
9
|
end
|
10
10
|
|
11
|
+
test "lookup: given a translation is a proc it passes the interpolation values as keyword arguments" do
|
12
|
+
I18n.backend.store_translations(:en, :a_lambda => lambda { |key, foo:, **| I18n::Tests::Procs.filter_args(key, foo: foo) })
|
13
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
|
14
|
+
end
|
15
|
+
|
11
16
|
test "defaults: given a default is a Proc it calls it with the key and interpolation values" do
|
12
17
|
proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) }
|
13
18
|
assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
data/lib/i18n/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -10,10 +10,10 @@ authors:
|
|
10
10
|
- Stephan Soller
|
11
11
|
- Saimon Moore
|
12
12
|
- Ryan Bigg
|
13
|
-
autorequire:
|
13
|
+
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2021-02-02 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: concurrent-ruby
|
@@ -37,17 +37,11 @@ extra_rdoc_files: []
|
|
37
37
|
files:
|
38
38
|
- MIT-LICENSE
|
39
39
|
- README.md
|
40
|
-
- gemfiles/Gemfile.rails-3.2.x
|
41
|
-
- gemfiles/Gemfile.rails-4.0.x
|
42
|
-
- gemfiles/Gemfile.rails-4.1.x
|
43
|
-
- gemfiles/Gemfile.rails-4.2.x
|
44
|
-
- gemfiles/Gemfile.rails-5.0.x
|
45
|
-
- gemfiles/Gemfile.rails-5.1.x
|
46
|
-
- gemfiles/Gemfile.rails-master
|
47
40
|
- lib/i18n.rb
|
48
41
|
- lib/i18n/backend.rb
|
49
42
|
- lib/i18n/backend/base.rb
|
50
43
|
- lib/i18n/backend/cache.rb
|
44
|
+
- lib/i18n/backend/cache_file.rb
|
51
45
|
- lib/i18n/backend/cascade.rb
|
52
46
|
- lib/i18n/backend/chain.rb
|
53
47
|
- lib/i18n/backend/fallbacks.rb
|
@@ -62,8 +56,6 @@ files:
|
|
62
56
|
- lib/i18n/backend/transliterator.rb
|
63
57
|
- lib/i18n/config.rb
|
64
58
|
- lib/i18n/core_ext/hash.rb
|
65
|
-
- lib/i18n/core_ext/kernel/suppress_warnings.rb
|
66
|
-
- lib/i18n/core_ext/string/interpolate.rb
|
67
59
|
- lib/i18n/exceptions.rb
|
68
60
|
- lib/i18n/gettext.rb
|
69
61
|
- lib/i18n/gettext/helpers.rb
|
@@ -90,52 +82,15 @@ files:
|
|
90
82
|
- lib/i18n/tests/pluralization.rb
|
91
83
|
- lib/i18n/tests/procs.rb
|
92
84
|
- lib/i18n/version.rb
|
93
|
-
|
94
|
-
- test/api/cascade_test.rb
|
95
|
-
- test/api/chain_test.rb
|
96
|
-
- test/api/fallbacks_test.rb
|
97
|
-
- test/api/key_value_test.rb
|
98
|
-
- test/api/memoize_test.rb
|
99
|
-
- test/api/override_test.rb
|
100
|
-
- test/api/pluralization_test.rb
|
101
|
-
- test/api/simple_test.rb
|
102
|
-
- test/backend/cache_test.rb
|
103
|
-
- test/backend/cascade_test.rb
|
104
|
-
- test/backend/chain_test.rb
|
105
|
-
- test/backend/exceptions_test.rb
|
106
|
-
- test/backend/fallbacks_test.rb
|
107
|
-
- test/backend/interpolation_compiler_test.rb
|
108
|
-
- test/backend/key_value_test.rb
|
109
|
-
- test/backend/memoize_test.rb
|
110
|
-
- test/backend/metadata_test.rb
|
111
|
-
- test/backend/pluralization_test.rb
|
112
|
-
- test/backend/simple_test.rb
|
113
|
-
- test/backend/transliterator_test.rb
|
114
|
-
- test/core_ext/hash_test.rb
|
115
|
-
- test/gettext/api_test.rb
|
116
|
-
- test/gettext/backend_test.rb
|
117
|
-
- test/i18n/exceptions_test.rb
|
118
|
-
- test/i18n/gettext_plural_keys_test.rb
|
119
|
-
- test/i18n/interpolate_test.rb
|
120
|
-
- test/i18n/load_path_test.rb
|
121
|
-
- test/i18n/middleware_test.rb
|
122
|
-
- test/i18n_test.rb
|
123
|
-
- test/locale/fallbacks_test.rb
|
124
|
-
- test/locale/tag/rfc4646_test.rb
|
125
|
-
- test/locale/tag/simple_test.rb
|
126
|
-
- test/run_all.rb
|
127
|
-
- test/test_data/locales/de.po
|
128
|
-
- test/test_data/locales/en.rb
|
129
|
-
- test/test_data/locales/en.yml
|
130
|
-
- test/test_data/locales/invalid/empty.yml
|
131
|
-
- test/test_data/locales/invalid/syntax.yml
|
132
|
-
- test/test_data/locales/plurals.rb
|
133
|
-
- test/test_helper.rb
|
134
|
-
homepage: http://github.com/svenfuchs/i18n
|
85
|
+
homepage: https://github.com/ruby-i18n/i18n
|
135
86
|
licenses:
|
136
87
|
- MIT
|
137
|
-
metadata:
|
138
|
-
|
88
|
+
metadata:
|
89
|
+
bug_tracker_uri: https://github.com/ruby-i18n/i18n/issues
|
90
|
+
changelog_uri: https://github.com/ruby-i18n/i18n/releases
|
91
|
+
documentation_uri: https://guides.rubyonrails.org/i18n.html
|
92
|
+
source_code_uri: https://github.com/ruby-i18n/i18n
|
93
|
+
post_install_message:
|
139
94
|
rdoc_options: []
|
140
95
|
require_paths:
|
141
96
|
- lib
|
@@ -143,16 +98,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
98
|
requirements:
|
144
99
|
- - ">="
|
145
100
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
101
|
+
version: 2.3.0
|
147
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
103
|
requirements:
|
149
104
|
- - ">="
|
150
105
|
- !ruby/object:Gem::Version
|
151
106
|
version: 1.3.5
|
152
107
|
requirements: []
|
153
|
-
|
154
|
-
|
155
|
-
signing_key:
|
108
|
+
rubygems_version: 3.2.3
|
109
|
+
signing_key:
|
156
110
|
specification_version: 4
|
157
111
|
summary: New wave Internationalization support for Ruby
|
158
112
|
test_files: []
|