i18n 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +125 -0
- data/lib/i18n.rb +398 -0
- data/lib/i18n/backend.rb +21 -0
- data/lib/i18n/backend/base.rb +284 -0
- data/lib/i18n/backend/cache.rb +113 -0
- data/lib/i18n/backend/cache_file.rb +36 -0
- data/lib/i18n/backend/cascade.rb +56 -0
- data/lib/i18n/backend/chain.rb +127 -0
- data/lib/i18n/backend/fallbacks.rb +84 -0
- data/lib/i18n/backend/flatten.rb +115 -0
- data/lib/i18n/backend/gettext.rb +85 -0
- data/lib/i18n/backend/interpolation_compiler.rb +123 -0
- data/lib/i18n/backend/key_value.rb +206 -0
- data/lib/i18n/backend/memoize.rb +54 -0
- data/lib/i18n/backend/metadata.rb +71 -0
- data/lib/i18n/backend/pluralization.rb +55 -0
- data/lib/i18n/backend/simple.rb +111 -0
- data/lib/i18n/backend/transliterator.rb +108 -0
- data/lib/i18n/config.rb +165 -0
- data/lib/i18n/core_ext/hash.rb +47 -0
- data/lib/i18n/exceptions.rb +111 -0
- data/lib/i18n/gettext.rb +28 -0
- data/lib/i18n/gettext/helpers.rb +75 -0
- data/lib/i18n/gettext/po_parser.rb +329 -0
- data/lib/i18n/interpolate/ruby.rb +39 -0
- data/lib/i18n/locale.rb +8 -0
- data/lib/i18n/locale/fallbacks.rb +96 -0
- data/lib/i18n/locale/tag.rb +28 -0
- data/lib/i18n/locale/tag/parents.rb +22 -0
- data/lib/i18n/locale/tag/rfc4646.rb +74 -0
- data/lib/i18n/locale/tag/simple.rb +39 -0
- data/lib/i18n/middleware.rb +17 -0
- data/lib/i18n/tests.rb +14 -0
- data/lib/i18n/tests/basics.rb +60 -0
- data/lib/i18n/tests/defaults.rb +52 -0
- data/lib/i18n/tests/interpolation.rb +159 -0
- data/lib/i18n/tests/link.rb +56 -0
- data/lib/i18n/tests/localization.rb +19 -0
- data/lib/i18n/tests/localization/date.rb +117 -0
- data/lib/i18n/tests/localization/date_time.rb +103 -0
- data/lib/i18n/tests/localization/procs.rb +116 -0
- data/lib/i18n/tests/localization/time.rb +103 -0
- data/lib/i18n/tests/lookup.rb +81 -0
- data/lib/i18n/tests/pluralization.rb +35 -0
- data/lib/i18n/tests/procs.rb +55 -0
- data/lib/i18n/version.rb +5 -0
- metadata +124 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Tests
|
5
|
+
module Localization
|
6
|
+
module Procs
|
7
|
+
test "localize: using day names from lambdas" do
|
8
|
+
setup_time_proc_translations
|
9
|
+
time = ::Time.utc(2008, 3, 1, 6, 0)
|
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
|
+
test "localize: using month names from lambdas" do
|
15
|
+
setup_time_proc_translations
|
16
|
+
time = ::Time.utc(2008, 3, 1, 6, 0)
|
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
|
+
test "localize: using abbreviated day names from lambdas" do
|
22
|
+
setup_time_proc_translations
|
23
|
+
time = ::Time.utc(2008, 3, 1, 6, 0)
|
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
|
+
test "localize Date: given a format that resolves to a Proc it calls the Proc with the object" do
|
29
|
+
setup_time_proc_translations
|
30
|
+
date = ::Date.new(2008, 3, 1)
|
31
|
+
assert_equal '[Sat, 01 Mar 2008, {}]', I18n.l(date, :format => :proc, :locale => :ru)
|
32
|
+
end
|
33
|
+
|
34
|
+
test "localize Date: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
35
|
+
setup_time_proc_translations
|
36
|
+
date = ::Date.new(2008, 3, 1)
|
37
|
+
assert_equal '[Sat, 01 Mar 2008, {:foo=>"foo"}]', I18n.l(date, :format => :proc, :foo => 'foo', :locale => :ru)
|
38
|
+
end
|
39
|
+
|
40
|
+
test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object" do
|
41
|
+
setup_time_proc_translations
|
42
|
+
datetime = ::DateTime.new(2008, 3, 1, 6)
|
43
|
+
assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {}]', I18n.l(datetime, :format => :proc, :locale => :ru)
|
44
|
+
end
|
45
|
+
|
46
|
+
test "localize DateTime: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
47
|
+
setup_time_proc_translations
|
48
|
+
datetime = ::DateTime.new(2008, 3, 1, 6)
|
49
|
+
assert_equal '[Sat, 01 Mar 2008 06:00:00 +00:00, {:foo=>"foo"}]', I18n.l(datetime, :format => :proc, :foo => 'foo', :locale => :ru)
|
50
|
+
end
|
51
|
+
|
52
|
+
test "localize Time: given a format that resolves to a Proc it calls the Proc with the object" do
|
53
|
+
setup_time_proc_translations
|
54
|
+
time = ::Time.utc(2008, 3, 1, 6, 0)
|
55
|
+
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, {}]), I18n.l(time, :format => :proc, :locale => :ru)
|
56
|
+
end
|
57
|
+
|
58
|
+
test "localize Time: given a format that resolves to a Proc it calls the Proc with the object and extra options" do
|
59
|
+
setup_time_proc_translations
|
60
|
+
time = ::Time.utc(2008, 3, 1, 6, 0)
|
61
|
+
options = { :foo => 'foo' }
|
62
|
+
assert_equal I18n::Tests::Localization::Procs.inspect_args([time, options]), I18n.l(time, options.merge(:format => :proc, :locale => :ru))
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
def self.inspect_args(args)
|
68
|
+
args = args.map do |arg|
|
69
|
+
case arg
|
70
|
+
when ::Time, ::DateTime
|
71
|
+
arg.strftime('%a, %d %b %Y %H:%M:%S %Z').sub('+0000', '+00:00')
|
72
|
+
when ::Date
|
73
|
+
arg.strftime('%a, %d %b %Y')
|
74
|
+
when Hash
|
75
|
+
arg.delete(:fallback_in_progress)
|
76
|
+
arg.inspect
|
77
|
+
else
|
78
|
+
arg.inspect
|
79
|
+
end
|
80
|
+
end
|
81
|
+
"[#{args.join(', ')}]"
|
82
|
+
end
|
83
|
+
|
84
|
+
def setup_time_proc_translations
|
85
|
+
I18n.backend.store_translations :ru, {
|
86
|
+
:time => {
|
87
|
+
:formats => {
|
88
|
+
:proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) }
|
89
|
+
}
|
90
|
+
},
|
91
|
+
:date => {
|
92
|
+
:formats => {
|
93
|
+
:proc => lambda { |*args| I18n::Tests::Localization::Procs.inspect_args(args) }
|
94
|
+
},
|
95
|
+
:'day_names' => lambda { |key, options|
|
96
|
+
(options[:format] =~ /^%A/) ?
|
97
|
+
%w(Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота) :
|
98
|
+
%w(воскресенье понедельник вторник среда четверг пятница суббота)
|
99
|
+
},
|
100
|
+
:'month_names' => lambda { |key, options|
|
101
|
+
(options[:format] =~ /(%d|%e)(\s*)?(%B)/) ?
|
102
|
+
%w(января февраля марта апреля мая июня июля августа сентября октября ноября декабря).unshift(nil) :
|
103
|
+
%w(Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь).unshift(nil)
|
104
|
+
},
|
105
|
+
:'abbr_month_names' => lambda { |key, options|
|
106
|
+
(options[:format] =~ /(%d|%e)(\s*)(%b)/) ?
|
107
|
+
%w(янв. февр. марта апр. мая июня июля авг. сент. окт. нояб. дек.).unshift(nil) :
|
108
|
+
%w(янв. февр. март апр. май июнь июль авг. сент. окт. нояб. дек.).unshift(nil)
|
109
|
+
},
|
110
|
+
}
|
111
|
+
}
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Tests
|
5
|
+
module Localization
|
6
|
+
module Time
|
7
|
+
def setup
|
8
|
+
super
|
9
|
+
setup_time_translations
|
10
|
+
@time = ::Time.utc(2008, 3, 1, 6, 0)
|
11
|
+
@other_time = ::Time.utc(2008, 3, 1, 18, 0)
|
12
|
+
end
|
13
|
+
|
14
|
+
test "localize Time: given the short format it uses it" do
|
15
|
+
assert_equal '01. Mär 06:00', I18n.l(@time, :format => :short, :locale => :de)
|
16
|
+
end
|
17
|
+
|
18
|
+
test "localize Time: given the long format it uses it" do
|
19
|
+
assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de)
|
20
|
+
end
|
21
|
+
|
22
|
+
# TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
|
23
|
+
# def test_localize_given_the_default_format_it_uses_it
|
24
|
+
# assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de)
|
25
|
+
# end
|
26
|
+
|
27
|
+
test "localize Time: given a day name format it returns the correct day name" do
|
28
|
+
assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de)
|
29
|
+
end
|
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
|
+
|
35
|
+
test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do
|
36
|
+
assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de)
|
37
|
+
end
|
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
|
+
|
43
|
+
test "localize Time: given a month name format it returns the correct month name" do
|
44
|
+
assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de)
|
45
|
+
end
|
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
|
+
|
51
|
+
test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do
|
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)
|
65
|
+
end
|
66
|
+
|
67
|
+
test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
|
68
|
+
assert_equal 'AM', I18n.l(@time, :format => '%p', :locale => :de)
|
69
|
+
assert_equal 'PM', I18n.l(@other_time, :format => '%p', :locale => :de)
|
70
|
+
end
|
71
|
+
|
72
|
+
test "localize Time: given a meridian indicator format it returns the correct meridian indicator in upcase" do
|
73
|
+
assert_equal 'am', I18n.l(@time, :format => '%P', :locale => :de)
|
74
|
+
assert_equal 'pm', I18n.l(@other_time, :format => '%P', :locale => :de)
|
75
|
+
end
|
76
|
+
|
77
|
+
test "localize Time: given an unknown format it does not fail" do
|
78
|
+
assert_nothing_raised { I18n.l(@time, :format => '%x') }
|
79
|
+
end
|
80
|
+
|
81
|
+
test "localize Time: given a format is missing it raises I18n::MissingTranslationData" do
|
82
|
+
assert_raise(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) }
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
def setup_time_translations
|
88
|
+
I18n.backend.store_translations :de, {
|
89
|
+
:time => {
|
90
|
+
:formats => {
|
91
|
+
:default => "%a, %d. %b %Y %H:%M:%S %z",
|
92
|
+
:short => "%d. %b %H:%M",
|
93
|
+
:long => "%d. %B %Y %H:%M",
|
94
|
+
},
|
95
|
+
:am => 'am',
|
96
|
+
:pm => 'pm'
|
97
|
+
}
|
98
|
+
}
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Tests
|
5
|
+
module Lookup
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
I18n.backend.store_translations(:en, :foo => { :bar => 'bar', :baz => 'baz' }, :falsy => false, :truthy => true,
|
9
|
+
:string => "a", :array => %w(a b c), :hash => { "a" => "b" })
|
10
|
+
end
|
11
|
+
|
12
|
+
test "lookup: it returns a string" do
|
13
|
+
assert_equal("a", I18n.t(:string))
|
14
|
+
end
|
15
|
+
|
16
|
+
test "lookup: it returns hash" do
|
17
|
+
assert_equal({ :a => "b" }, I18n.t(:hash))
|
18
|
+
end
|
19
|
+
|
20
|
+
test "lookup: it returns an array" do
|
21
|
+
assert_equal(%w(a b c), I18n.t(:array))
|
22
|
+
end
|
23
|
+
|
24
|
+
test "lookup: it returns a native true" do
|
25
|
+
assert I18n.t(:truthy) === true
|
26
|
+
end
|
27
|
+
|
28
|
+
test "lookup: it returns a native false" do
|
29
|
+
assert I18n.t(:falsy) === false
|
30
|
+
end
|
31
|
+
|
32
|
+
test "lookup: given a missing key, no default and no raise option it returns an error message" do
|
33
|
+
assert_equal "translation missing: en.missing", I18n.t(:missing)
|
34
|
+
end
|
35
|
+
|
36
|
+
test "lookup: given a missing key, no default and the raise option it raises MissingTranslationData" do
|
37
|
+
assert_raise(I18n::MissingTranslationData) { I18n.t(:missing, :raise => true) }
|
38
|
+
end
|
39
|
+
|
40
|
+
test "lookup: does not raise an exception if no translation data is present for the given locale" do
|
41
|
+
assert_nothing_raised { I18n.t(:foo, :locale => :xx) }
|
42
|
+
end
|
43
|
+
|
44
|
+
test "lookup: does not modify the options hash" do
|
45
|
+
options = {}
|
46
|
+
assert_equal "a", I18n.t(:string, options)
|
47
|
+
assert_equal({}, options)
|
48
|
+
assert_nothing_raised { I18n.t(:string, options.freeze) }
|
49
|
+
end
|
50
|
+
|
51
|
+
test "lookup: given an array of keys it translates all of them" do
|
52
|
+
assert_equal %w(bar baz), I18n.t([:bar, :baz], :scope => [:foo])
|
53
|
+
end
|
54
|
+
|
55
|
+
test "lookup: using a custom scope separator" do
|
56
|
+
# data must have been stored using the custom separator when using the ActiveRecord backend
|
57
|
+
I18n.backend.store_translations(:en, { :foo => { :bar => 'bar' } }, { :separator => '|' })
|
58
|
+
assert_equal 'bar', I18n.t('foo|bar', :separator => '|')
|
59
|
+
end
|
60
|
+
|
61
|
+
# In fact it probably *should* fail but Rails currently relies on using the default locale instead.
|
62
|
+
# So we'll stick to this for now until we get it fixed in Rails.
|
63
|
+
test "lookup: given nil as a locale it does not raise but use the default locale" do
|
64
|
+
# assert_raise(I18n::InvalidLocale) { I18n.t(:bar, :locale => nil) }
|
65
|
+
assert_nothing_raised { I18n.t(:bar, :locale => nil) }
|
66
|
+
end
|
67
|
+
|
68
|
+
test "lookup: a resulting String is not frozen" do
|
69
|
+
assert !I18n.t(:string).frozen?
|
70
|
+
end
|
71
|
+
|
72
|
+
test "lookup: a resulting Array is not frozen" do
|
73
|
+
assert !I18n.t(:array).frozen?
|
74
|
+
end
|
75
|
+
|
76
|
+
test "lookup: a resulting Hash is not frozen" do
|
77
|
+
assert !I18n.t(:hash).frozen?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Tests
|
5
|
+
module Pluralization
|
6
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
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
|
+
test "pluralization: given incomplete pluralization data it raises I18n::InvalidPluralizationData" do
|
31
|
+
assert_raise(I18n::InvalidPluralizationData) { I18n.t(:default => { :one => 'bar' }, :count => 2) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module I18n
|
4
|
+
module Tests
|
5
|
+
module Procs
|
6
|
+
test "lookup: given a translation is a proc it calls the proc with the key and interpolation values" do
|
7
|
+
I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) })
|
8
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(:a_lambda, :foo => 'foo')
|
9
|
+
end
|
10
|
+
|
11
|
+
test "defaults: given a default is a Proc it calls it with the key and interpolation values" do
|
12
|
+
proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) }
|
13
|
+
assert_equal '[nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
14
|
+
end
|
15
|
+
|
16
|
+
test "defaults: given a default is a key that resolves to a Proc it calls it with the key and interpolation values" do
|
17
|
+
the_lambda = lambda { |*args| I18n::Tests::Procs.filter_args(*args) }
|
18
|
+
I18n.backend.store_translations(:en, :a_lambda => the_lambda)
|
19
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => :a_lambda, :foo => 'foo')
|
20
|
+
assert_equal '[:a_lambda, {:foo=>"foo"}]', I18n.t(nil, :default => [nil, :a_lambda], :foo => 'foo')
|
21
|
+
end
|
22
|
+
|
23
|
+
test "interpolation: given an interpolation value is a lambda it calls it with key and values before interpolating it" do
|
24
|
+
proc = lambda { |*args| I18n::Tests::Procs.filter_args(*args) }
|
25
|
+
assert_match %r(\[\{:foo=>#<Proc.*>\}\]), I18n.t(nil, :default => '%{foo}', :foo => proc)
|
26
|
+
end
|
27
|
+
|
28
|
+
test "interpolation: given a key resolves to a Proc that returns a string then interpolation still works" do
|
29
|
+
proc = lambda { |*args| "%{foo}: " + I18n::Tests::Procs.filter_args(*args) }
|
30
|
+
assert_equal 'foo: [nil, {:foo=>"foo"}]', I18n.t(nil, :default => proc, :foo => 'foo')
|
31
|
+
end
|
32
|
+
|
33
|
+
test "pluralization: given a key resolves to a Proc that returns valid data then pluralization still works" do
|
34
|
+
proc = lambda { |*args| { :zero => 'zero', :one => 'one', :other => 'other' } }
|
35
|
+
assert_equal 'zero', I18n.t(:default => proc, :count => 0)
|
36
|
+
assert_equal 'one', I18n.t(:default => proc, :count => 1)
|
37
|
+
assert_equal 'other', I18n.t(:default => proc, :count => 2)
|
38
|
+
end
|
39
|
+
|
40
|
+
test "lookup: given the option :resolve => false was passed it does not resolve proc translations" do
|
41
|
+
I18n.backend.store_translations(:en, :a_lambda => lambda { |*args| I18n::Tests::Procs.filter_args(*args) })
|
42
|
+
assert_equal Proc, I18n.t(:a_lambda, :resolve => false).class
|
43
|
+
end
|
44
|
+
|
45
|
+
test "lookup: given the option :resolve => false was passed it does not resolve proc default" do
|
46
|
+
assert_equal Proc, I18n.t(nil, :default => lambda { |*args| I18n::Tests::Procs.filter_args(*args) }, :resolve => false).class
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def self.filter_args(*args)
|
51
|
+
args.map {|arg| arg.delete(:fallback_in_progress) if arg.is_a?(Hash) ; arg }.inspect
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/i18n/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: i18n
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven Fuchs
|
8
|
+
- Joshua Harvey
|
9
|
+
- Matt Aimonetti
|
10
|
+
- Stephan Soller
|
11
|
+
- Saimon Moore
|
12
|
+
- Ryan Bigg
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: concurrent-ruby
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - "~>"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '1.0'
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - "~>"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '1.0'
|
32
|
+
description: New wave Internationalization support for Ruby.
|
33
|
+
email: rails-i18n@googlegroups.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- MIT-LICENSE
|
39
|
+
- README.md
|
40
|
+
- lib/i18n.rb
|
41
|
+
- lib/i18n/backend.rb
|
42
|
+
- lib/i18n/backend/base.rb
|
43
|
+
- lib/i18n/backend/cache.rb
|
44
|
+
- lib/i18n/backend/cache_file.rb
|
45
|
+
- lib/i18n/backend/cascade.rb
|
46
|
+
- lib/i18n/backend/chain.rb
|
47
|
+
- lib/i18n/backend/fallbacks.rb
|
48
|
+
- lib/i18n/backend/flatten.rb
|
49
|
+
- lib/i18n/backend/gettext.rb
|
50
|
+
- lib/i18n/backend/interpolation_compiler.rb
|
51
|
+
- lib/i18n/backend/key_value.rb
|
52
|
+
- lib/i18n/backend/memoize.rb
|
53
|
+
- lib/i18n/backend/metadata.rb
|
54
|
+
- lib/i18n/backend/pluralization.rb
|
55
|
+
- lib/i18n/backend/simple.rb
|
56
|
+
- lib/i18n/backend/transliterator.rb
|
57
|
+
- lib/i18n/config.rb
|
58
|
+
- lib/i18n/core_ext/hash.rb
|
59
|
+
- lib/i18n/exceptions.rb
|
60
|
+
- lib/i18n/gettext.rb
|
61
|
+
- lib/i18n/gettext/helpers.rb
|
62
|
+
- lib/i18n/gettext/po_parser.rb
|
63
|
+
- lib/i18n/interpolate/ruby.rb
|
64
|
+
- lib/i18n/locale.rb
|
65
|
+
- lib/i18n/locale/fallbacks.rb
|
66
|
+
- lib/i18n/locale/tag.rb
|
67
|
+
- lib/i18n/locale/tag/parents.rb
|
68
|
+
- lib/i18n/locale/tag/rfc4646.rb
|
69
|
+
- lib/i18n/locale/tag/simple.rb
|
70
|
+
- lib/i18n/middleware.rb
|
71
|
+
- lib/i18n/tests.rb
|
72
|
+
- lib/i18n/tests/basics.rb
|
73
|
+
- lib/i18n/tests/defaults.rb
|
74
|
+
- lib/i18n/tests/interpolation.rb
|
75
|
+
- lib/i18n/tests/link.rb
|
76
|
+
- lib/i18n/tests/localization.rb
|
77
|
+
- lib/i18n/tests/localization/date.rb
|
78
|
+
- lib/i18n/tests/localization/date_time.rb
|
79
|
+
- lib/i18n/tests/localization/procs.rb
|
80
|
+
- lib/i18n/tests/localization/time.rb
|
81
|
+
- lib/i18n/tests/lookup.rb
|
82
|
+
- lib/i18n/tests/pluralization.rb
|
83
|
+
- lib/i18n/tests/procs.rb
|
84
|
+
- lib/i18n/version.rb
|
85
|
+
homepage: http://github.com/ruby-i18n/i18n
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata:
|
89
|
+
bug_tracker_uri: https://github.com/svenfuchs/i18n/issues
|
90
|
+
changelog_uri: https://github.com/svenfuchs/i18n/releases
|
91
|
+
documentation_uri: https://guides.rubyonrails.org/i18n.html
|
92
|
+
source_code_uri: https://github.com/svenfuchs/i18n
|
93
|
+
post_install_message: |2+
|
94
|
+
|
95
|
+
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
|
96
|
+
But that may break your application.
|
97
|
+
|
98
|
+
Please check your Rails app for 'config.i18n.fallbacks = true'.
|
99
|
+
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
|
100
|
+
'config.i18n.fallbacks = [I18n.default_locale]'.
|
101
|
+
If not, fallbacks will be broken in your app by I18n 1.1.x.
|
102
|
+
|
103
|
+
For more info see:
|
104
|
+
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
|
105
|
+
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 2.3.0
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.3.5
|
119
|
+
requirements: []
|
120
|
+
rubygems_version: 3.0.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: New wave Internationalization support for Ruby
|
124
|
+
test_files: []
|