i18n 0.7.0.beta1 → 0.7.0
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.
- checksums.yaml +4 -4
- data/gemfiles/Gemfile.rails-3.2.x.lock +3 -3
- data/gemfiles/Gemfile.rails-4.0.x.lock +4 -4
- data/gemfiles/Gemfile.rails-4.1.x.lock +5 -5
- data/gemfiles/Gemfile.rails-4.2.x +8 -0
- data/gemfiles/Gemfile.rails-4.2.x.lock +34 -0
- data/gemfiles/Gemfile.rails-master.lock +9 -9
- data/lib/i18n/backend/chain.rb +16 -2
- data/lib/i18n/core_ext/string/interpolate.rb +9 -0
- data/lib/i18n/tests/lookup.rb +1 -1
- data/lib/i18n/version.rb +1 -1
- data/test/backend/chain_test.rb +20 -6
- data/test/i18n_test.rb +14 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c21c5ff9dda205f54c1156967092f364c009ec
|
4
|
+
data.tar.gz: dd22c6d9398d5ab012e86d9e9e149158bc7d3731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751f36baefacf168a3473f84d4b4f4a0a6c1da62acb51d78bfa4a1926dc6ba242bf4fa2ccd4263f07491a5c036f1eb37cc750efe5f8f227caf169d838bbfd87e
|
7
|
+
data.tar.gz: 657f8618ea7c530a4ea77d250bda199b28eb7b1f3a7429156ee4f82de3b0481f94daf0b9833c2f31dffb8487e9355b90e0b123e00f173fc205331345322248ef
|
@@ -1,19 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
i18n (0.7.0
|
4
|
+
i18n (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (3.2.
|
9
|
+
activesupport (3.2.21)
|
10
10
|
i18n (~> 0.6, >= 0.6.4)
|
11
11
|
multi_json (~> 1.0)
|
12
12
|
metaclass (0.0.4)
|
13
13
|
mocha (1.1.0)
|
14
14
|
metaclass (~> 0.0.1)
|
15
15
|
multi_json (1.10.1)
|
16
|
-
rake (10.
|
16
|
+
rake (10.4.2)
|
17
17
|
test_declarative (0.0.5)
|
18
18
|
|
19
19
|
PLATFORMS
|
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
i18n (0.7.0
|
4
|
+
i18n (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (4.0.
|
9
|
+
activesupport (4.0.12)
|
10
10
|
i18n (~> 0.6, >= 0.6.9)
|
11
11
|
minitest (~> 4.2)
|
12
12
|
multi_json (~> 1.3)
|
@@ -17,10 +17,10 @@ GEM
|
|
17
17
|
mocha (1.1.0)
|
18
18
|
metaclass (~> 0.0.1)
|
19
19
|
multi_json (1.10.1)
|
20
|
-
rake (10.
|
20
|
+
rake (10.4.2)
|
21
21
|
test_declarative (0.0.5)
|
22
22
|
thread_safe (0.3.4)
|
23
|
-
tzinfo (0.3.
|
23
|
+
tzinfo (0.3.42)
|
24
24
|
|
25
25
|
PLATFORMS
|
26
26
|
ruby
|
@@ -1,12 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
i18n (0.7.0
|
4
|
+
i18n (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
activesupport (4.1.
|
9
|
+
activesupport (4.1.8)
|
10
10
|
i18n (~> 0.6, >= 0.6.9)
|
11
11
|
json (~> 1.7, >= 1.7.7)
|
12
12
|
minitest (~> 5.1)
|
@@ -14,13 +14,13 @@ GEM
|
|
14
14
|
tzinfo (~> 1.1)
|
15
15
|
json (1.8.1)
|
16
16
|
metaclass (0.0.4)
|
17
|
-
minitest (5.
|
17
|
+
minitest (5.5.0)
|
18
18
|
mocha (1.1.0)
|
19
19
|
metaclass (~> 0.0.1)
|
20
|
-
rake (10.
|
20
|
+
rake (10.4.2)
|
21
21
|
test_declarative (0.0.5)
|
22
22
|
thread_safe (0.3.4)
|
23
|
-
tzinfo (1.2.
|
23
|
+
tzinfo (1.2.2)
|
24
24
|
thread_safe (~> 0.1)
|
25
25
|
|
26
26
|
PLATFORMS
|
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
i18n (0.7.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.2.0.rc3)
|
10
|
+
i18n (>= 0.7.0.beta1, < 0.8)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
json (1.8.1)
|
16
|
+
metaclass (0.0.4)
|
17
|
+
minitest (5.5.0)
|
18
|
+
mocha (1.1.0)
|
19
|
+
metaclass (~> 0.0.1)
|
20
|
+
rake (10.4.2)
|
21
|
+
test_declarative (0.0.5)
|
22
|
+
thread_safe (0.3.4)
|
23
|
+
tzinfo (1.2.2)
|
24
|
+
thread_safe (~> 0.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
activesupport (~> 4.2.0.rc3)
|
31
|
+
i18n!
|
32
|
+
mocha
|
33
|
+
rake
|
34
|
+
test_declarative
|
@@ -1,29 +1,29 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.7.0.beta1)
|
5
|
-
|
6
1
|
GIT
|
7
2
|
remote: git://github.com/rails/rails.git
|
8
|
-
revision:
|
3
|
+
revision: fe46f009be1ece58e45abc51195e2381a71bd023
|
9
4
|
branch: master
|
10
5
|
specs:
|
11
|
-
activesupport (
|
6
|
+
activesupport (5.0.0.alpha)
|
12
7
|
i18n (>= 0.7.0.beta1, < 0.8)
|
13
8
|
json (~> 1.7, >= 1.7.7)
|
14
9
|
minitest (~> 5.1)
|
15
10
|
thread_safe (~> 0.1)
|
16
11
|
tzinfo (~> 1.1)
|
17
12
|
|
13
|
+
PATH
|
14
|
+
remote: ..
|
15
|
+
specs:
|
16
|
+
i18n (0.7.0)
|
17
|
+
|
18
18
|
GEM
|
19
19
|
remote: https://rubygems.org/
|
20
20
|
specs:
|
21
21
|
json (1.8.1)
|
22
22
|
metaclass (0.0.4)
|
23
|
-
minitest (5.
|
23
|
+
minitest (5.5.0)
|
24
24
|
mocha (1.1.0)
|
25
25
|
metaclass (~> 0.0.1)
|
26
|
-
rake (10.
|
26
|
+
rake (10.4.2)
|
27
27
|
test_declarative (0.0.5)
|
28
28
|
thread_safe (0.3.4)
|
29
29
|
tzinfo (1.2.2)
|
data/lib/i18n/backend/chain.rb
CHANGED
@@ -17,7 +17,7 @@ module I18n
|
|
17
17
|
class Chain
|
18
18
|
module Implementation
|
19
19
|
include Base
|
20
|
-
|
20
|
+
|
21
21
|
attr_accessor :backends
|
22
22
|
|
23
23
|
def initialize(*backends)
|
@@ -45,7 +45,7 @@ module I18n
|
|
45
45
|
options = default_options if backend == backends.last
|
46
46
|
translation = backend.translate(locale, key, options)
|
47
47
|
if namespace_lookup?(translation, options)
|
48
|
-
namespace = translation
|
48
|
+
namespace = _deep_merge(translation, namespace || {})
|
49
49
|
elsif !translation.nil?
|
50
50
|
return translation
|
51
51
|
end
|
@@ -75,6 +75,20 @@ module I18n
|
|
75
75
|
def namespace_lookup?(result, options)
|
76
76
|
result.is_a?(Hash) && !options.has_key?(:count)
|
77
77
|
end
|
78
|
+
|
79
|
+
private
|
80
|
+
# This is approximately what gets used in ActiveSupport.
|
81
|
+
# However since we are not guaranteed to run in an ActiveSupport context
|
82
|
+
# it is wise to have our own copy. We underscore it
|
83
|
+
# to not pollute the namespace of the including class.
|
84
|
+
def _deep_merge(hash, other_hash)
|
85
|
+
copy = hash.dup
|
86
|
+
other_hash.each_pair do |k,v|
|
87
|
+
value_from_other = hash[k]
|
88
|
+
copy[k] = value_from_other.is_a?(Hash) && v.is_a?(Hash) ? _deep_merge(value_from_other, v) : v
|
89
|
+
end
|
90
|
+
copy
|
91
|
+
end
|
78
92
|
end
|
79
93
|
|
80
94
|
include Implementation
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# This file used to backport the Ruby 1.9 String interpolation syntax to Ruby 1.8.
|
2
|
+
#
|
3
|
+
# Since I18n has dropped support to Ruby 1.8, this file is not required anymore,
|
4
|
+
# however, Rails 3.2 still requires it directly:
|
5
|
+
#
|
6
|
+
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/string/interpolation.rb#L2
|
7
|
+
#
|
8
|
+
# So we can't just drop the file entirely, which would then break Rails users
|
9
|
+
# under Ruby 1.9. This file can be removed once Rails 3.2 support is dropped.
|
data/lib/i18n/tests/lookup.rb
CHANGED
data/lib/i18n/version.rb
CHANGED
data/test/backend/chain_test.rb
CHANGED
@@ -4,10 +4,20 @@ class I18nBackendChainTest < I18n::TestCase
|
|
4
4
|
def setup
|
5
5
|
super
|
6
6
|
@first = backend(:en => {
|
7
|
-
:foo => 'Foo', :formats => {
|
7
|
+
:foo => 'Foo', :formats => {
|
8
|
+
:short => 'short',
|
9
|
+
:subformats => {:short => 'short'},
|
10
|
+
},
|
11
|
+
:plural_1 => { :one => '%{count}' },
|
12
|
+
:dates => {:a => "A"}
|
8
13
|
})
|
9
14
|
@second = backend(:en => {
|
10
|
-
:bar => 'Bar', :formats => {
|
15
|
+
:bar => 'Bar', :formats => {
|
16
|
+
:long => 'long',
|
17
|
+
:subformats => {:long => 'long'},
|
18
|
+
},
|
19
|
+
:plural_2 => { :one => 'one' },
|
20
|
+
:dates => {:a => "B", :b => "B"}
|
11
21
|
})
|
12
22
|
@chain = I18n.backend = I18n::Backend::Chain.new(@first, @second)
|
13
23
|
end
|
@@ -39,11 +49,11 @@ class I18nBackendChainTest < I18n::TestCase
|
|
39
49
|
assert_equal({}, I18n.t(:'i18n.transliterate.rule', :locale => 'en', :default => {}))
|
40
50
|
end
|
41
51
|
|
42
|
-
test "namespace lookup collects results from all backends" do
|
43
|
-
assert_equal({
|
52
|
+
test "namespace lookup collects results from all backends and merges deep hashes" do
|
53
|
+
assert_equal({:long=>"long", :subformats=>{:long=>"long", :short=>"short"}, :short=>"short"}, I18n.t(:formats))
|
44
54
|
end
|
45
55
|
|
46
|
-
test "namespace lookup collects results from all backends and
|
56
|
+
test "namespace lookup collects results from all backends and lets leftmost backend take priority" do
|
47
57
|
assert_equal({ :a => "A", :b => "B" }, I18n.t(:dates))
|
48
58
|
end
|
49
59
|
|
@@ -59,7 +69,11 @@ class I18nBackendChainTest < I18n::TestCase
|
|
59
69
|
test "bulk lookup collects results from all backends" do
|
60
70
|
assert_equal ['Foo', 'Bar'], I18n.t([:foo, :bar])
|
61
71
|
assert_equal ['Foo', 'Bar', 'Bah'], I18n.t([:foo, :bar, :bah], :default => 'Bah')
|
62
|
-
assert_equal [{
|
72
|
+
assert_equal [{
|
73
|
+
:long=>"long",
|
74
|
+
:subformats=>{:long=>"long", :short=>"short"},
|
75
|
+
:short=>"short"}, {:one=>"one"},
|
76
|
+
"Bah"], I18n.t([:formats, :plural_2, :bah], :default => 'Bah')
|
63
77
|
end
|
64
78
|
|
65
79
|
test "store_translations options are not dropped while transfering to backend" do
|
data/test/i18n_test.rb
CHANGED
@@ -388,9 +388,17 @@ class I18nTest < I18n::TestCase
|
|
388
388
|
I18n.config.enforce_available_locales = false
|
389
389
|
end
|
390
390
|
end
|
391
|
-
|
391
|
+
|
392
392
|
test 'I18n.reload! reloads the set of locales that are enforced' do
|
393
393
|
begin
|
394
|
+
# Clear the backend that affects the available locales and somehow can remain
|
395
|
+
# set from the last running test.
|
396
|
+
# For instance, it contains enough translations to cause a false positive with
|
397
|
+
# this test when ran with --seed=50992
|
398
|
+
I18n.backend = I18n::Backend::Simple.new
|
399
|
+
|
400
|
+
assert !I18n.available_locales.include?(:de), "Available locales should not include :de at this point"
|
401
|
+
|
394
402
|
I18n.enforce_available_locales = true
|
395
403
|
|
396
404
|
assert_raise(I18n::InvalidLocale) { I18n.default_locale = :de }
|
@@ -406,7 +414,11 @@ class I18nTest < I18n::TestCase
|
|
406
414
|
store_translations(:en, :foo => 'Foo in :en')
|
407
415
|
store_translations(:de, :foo => 'Foo in :de')
|
408
416
|
store_translations(:pl, :foo => 'Foo in :pl')
|
409
|
-
|
417
|
+
|
418
|
+
assert I18n.available_locales.include?(:de), ":de should now be allowed"
|
419
|
+
assert I18n.available_locales.include?(:en), ":en should now be allowed"
|
420
|
+
assert I18n.available_locales.include?(:pl), ":pl should now be allowed"
|
421
|
+
|
410
422
|
assert_nothing_raised { I18n.default_locale = I18n.locale = :en }
|
411
423
|
assert_nothing_raised { I18n.default_locale = I18n.locale = :de }
|
412
424
|
assert_nothing_raised { I18n.default_locale = I18n.locale = :pl }
|
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: 0.7.0
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-12-19 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: New wave Internationalization support for Ruby.
|
18
18
|
email: rails-i18n@googlegroups.com
|
@@ -28,6 +28,8 @@ files:
|
|
28
28
|
- gemfiles/Gemfile.rails-4.0.x.lock
|
29
29
|
- gemfiles/Gemfile.rails-4.1.x
|
30
30
|
- gemfiles/Gemfile.rails-4.1.x.lock
|
31
|
+
- gemfiles/Gemfile.rails-4.2.x
|
32
|
+
- gemfiles/Gemfile.rails-4.2.x.lock
|
31
33
|
- gemfiles/Gemfile.rails-master
|
32
34
|
- gemfiles/Gemfile.rails-master.lock
|
33
35
|
- lib/i18n.rb
|
@@ -49,6 +51,7 @@ files:
|
|
49
51
|
- lib/i18n/config.rb
|
50
52
|
- lib/i18n/core_ext/hash.rb
|
51
53
|
- lib/i18n/core_ext/kernel/suppress_warnings.rb
|
54
|
+
- lib/i18n/core_ext/string/interpolate.rb
|
52
55
|
- lib/i18n/exceptions.rb
|
53
56
|
- lib/i18n/gettext.rb
|
54
57
|
- lib/i18n/gettext/helpers.rb
|
@@ -125,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
128
|
requirements:
|
126
129
|
- - ">="
|
127
130
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
131
|
+
version: 1.9.3
|
129
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
133
|
requirements:
|
131
134
|
- - ">="
|
@@ -133,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
136
|
version: 1.3.5
|
134
137
|
requirements: []
|
135
138
|
rubyforge_project: "[none]"
|
136
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.4.3
|
137
140
|
signing_key:
|
138
141
|
specification_version: 4
|
139
142
|
summary: New wave Internationalization support for Ruby
|