i18n 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/i18n/backend/fallbacks.rb +4 -3
- data/lib/i18n/core_ext/hash.rb +2 -2
- data/lib/i18n/version.rb +1 -1
- data/test/backend/cache_test.rb +1 -0
- data/test/backend/fallbacks_test.rb +4 -0
- data/test/core_ext/hash_test.rb +0 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74991fa815d721be21fc8f4cb3d10dbe7c069059
|
4
|
+
data.tar.gz: 9f325a9e4bc99bc01883448c5871fc13f1eff5a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641844afc32707026b98596528a19fe177fef51e5d681f98db746d1980315c85f864dab53c5390f62f4d143d31b68b75f41b88e780478f0b00bde9e9e6cbf7dc
|
7
|
+
data.tar.gz: f62868e06de0b22744316dfcc74d1e928c6263552043bfea8dfbfd985ad660dbdc404e8324d6b5a85dd62d8355935e8cb999a2c21f540fe5fd68725041d05b21
|
@@ -37,8 +37,7 @@ module I18n
|
|
37
37
|
def translate(locale, key, options = {})
|
38
38
|
return super unless options.fetch(:fallback, true)
|
39
39
|
return super if options[:fallback_in_progress]
|
40
|
-
|
41
|
-
extract_non_symbol_default!(options)
|
40
|
+
default = extract_non_symbol_default!(options) if options[:default]
|
42
41
|
|
43
42
|
begin
|
44
43
|
options[:fallback_in_progress] = true
|
@@ -56,7 +55,9 @@ module I18n
|
|
56
55
|
options.delete(:fallback_in_progress)
|
57
56
|
end
|
58
57
|
|
59
|
-
return
|
58
|
+
return if options.key?(:default) && options[:default].nil?
|
59
|
+
|
60
|
+
return super(locale, nil, options.merge(:default => default)) if default
|
60
61
|
throw(:exception, I18n::MissingTranslation.new(locale, key, options))
|
61
62
|
end
|
62
63
|
|
data/lib/i18n/core_ext/hash.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Hash
|
2
2
|
def slice(*keep_keys)
|
3
|
-
h =
|
3
|
+
h = {}
|
4
4
|
keep_keys.each { |key| h[key] = fetch(key) if has_key?(key) }
|
5
5
|
h
|
6
6
|
end unless Hash.method_defined?(:slice)
|
@@ -21,7 +21,7 @@ class Hash
|
|
21
21
|
MERGER = proc do |key, v1, v2|
|
22
22
|
Hash === v1 && Hash === v2 ? v1.merge(v2, &MERGER) : v2
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def deep_merge!(data)
|
26
26
|
merge!(data, &MERGER)
|
27
27
|
end unless Hash.method_defined?(:deep_merge!)
|
data/lib/i18n/version.rb
CHANGED
data/test/backend/cache_test.rb
CHANGED
@@ -64,6 +64,10 @@ class I18nBackendFallbacksTranslateTest < I18n::TestCase
|
|
64
64
|
assert_nil I18n.t(:missing_bar, :locale => :'de-DE', :default => nil)
|
65
65
|
end
|
66
66
|
|
67
|
+
test "returns the translation missing message if the default is also missing" do
|
68
|
+
assert_equal 'translation missing: de-DE.missing_bar', I18n.t(:missing_bar, :locale => :'de-DE', :default => [:missing_baz])
|
69
|
+
end
|
70
|
+
|
67
71
|
test "returns the :'de-DE' default :baz translation for a missing :'de-DE' when defaults contains Symbol" do
|
68
72
|
assert_equal 'Baz in :de-DE', I18n.t(:missing_foo, :locale => :'de-DE', :default => [:baz, "Default Bar"])
|
69
73
|
end
|
data/test/core_ext/hash_test.rb
CHANGED
@@ -20,12 +20,6 @@ class I18nCoreExtHashInterpolationTest < I18n::TestCase
|
|
20
20
|
assert_equal expected, hash.slice(:foo, :not_here)
|
21
21
|
end
|
22
22
|
|
23
|
-
test "#slice maintains subclasses of Hash" do
|
24
|
-
klass = Class.new(Hash)
|
25
|
-
hash = klass[:foo, 'bar', :baz, 'bar']
|
26
|
-
assert_instance_of klass, hash.slice(:foo)
|
27
|
-
end
|
28
|
-
|
29
23
|
test "#except" do
|
30
24
|
hash = { :foo => 'bar', :baz => 'bar' }
|
31
25
|
expected = { :foo => 'bar' }
|
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.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Fuchs
|
@@ -9,10 +9,11 @@ authors:
|
|
9
9
|
- Matt Aimonetti
|
10
10
|
- Stephan Soller
|
11
11
|
- Saimon Moore
|
12
|
+
- Ryan Bigg
|
12
13
|
autorequire:
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
|
-
date: 2017-
|
16
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
16
17
|
dependencies:
|
17
18
|
- !ruby/object:Gem::Dependency
|
18
19
|
name: concurrent-ruby
|