i18n 0.8.0 → 0.8.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/backend/transliterator.rb +2 -1
- data/lib/i18n/tests/basics.rb +3 -2
- data/lib/i18n/tests/defaults.rb +1 -1
- data/lib/i18n/version.rb +1 -1
- data/test/backend/fallbacks_test.rb +9 -1
- data/test/i18n_test.rb +5 -1
- metadata +2 -8
- data/gemfiles/Gemfile.rails-3.2.x.lock +0 -32
- data/gemfiles/Gemfile.rails-4.0.x.lock +0 -37
- data/gemfiles/Gemfile.rails-4.1.x.lock +0 -38
- data/gemfiles/Gemfile.rails-4.2.x.lock +0 -38
- data/gemfiles/Gemfile.rails-5.0.x.lock +0 -37
- data/gemfiles/Gemfile.rails-master.lock +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 233c2489c16a63d11d29c05a13517dd6674e52ce
|
4
|
+
data.tar.gz: b55ebffc18d9e3c9f75a54175858031e8f57d8d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ed5bf64190812f81bfb29e9ce40608cdeb1330041c7d1bc02702189b88cb2e840506c977ae39713022acbcf850580f826c80e2f1492eae8194df860e492919c
|
7
|
+
data.tar.gz: 618f79c6b7469abd1cb0c92c100974073e13f4e16b2a429213b880383122cc9d5ecd461f5398a19693d63bf4fbb095e31e1ee8f97074c8e4ed394e6227d64a0b
|
@@ -35,11 +35,12 @@ module I18n
|
|
35
35
|
# it's a Symbol. When the default contains a String, Proc or Hash
|
36
36
|
# it is evaluated last after all the fallback locales have been tried.
|
37
37
|
def translate(locale, key, options = {})
|
38
|
-
return super
|
38
|
+
return super unless options.fetch(:fallback, true)
|
39
|
+
return super if (@fallback_locked ||= false)
|
39
40
|
default = extract_non_symbol_default!(options) if options[:default]
|
40
41
|
|
41
42
|
begin
|
42
|
-
|
43
|
+
@fallback_locked = true
|
43
44
|
I18n.fallbacks[locale].each do |fallback|
|
44
45
|
begin
|
45
46
|
catch(:exception) do
|
@@ -51,7 +52,7 @@ module I18n
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
ensure
|
54
|
-
|
55
|
+
@fallback_locked = false
|
55
56
|
end
|
56
57
|
|
57
58
|
return super(locale, nil, options.merge(:default => default)) if default
|
@@ -75,7 +75,8 @@ module I18n
|
|
75
75
|
add rule if rule
|
76
76
|
end
|
77
77
|
|
78
|
-
def transliterate(string, replacement =
|
78
|
+
def transliterate(string, replacement = nil)
|
79
|
+
replacement ||= DEFAULT_REPLACEMENT_CHAR
|
79
80
|
string.gsub(/[^\x00-\x7f]/u) do |char|
|
80
81
|
approximations[char] || replacement
|
81
82
|
end
|
data/lib/i18n/tests/basics.rb
CHANGED
@@ -37,8 +37,9 @@ module I18n
|
|
37
37
|
end
|
38
38
|
|
39
39
|
test "available_locales delegates to the backend when not set explicitely" do
|
40
|
-
I18n.backend.
|
41
|
-
|
40
|
+
original_available_locales_value = I18n.backend.available_locales
|
41
|
+
I18n.backend.expects(:available_locales).returns(original_available_locales_value).twice
|
42
|
+
assert_equal I18n.backend.available_locales, I18n.available_locales
|
42
43
|
end
|
43
44
|
|
44
45
|
test "exists? is implemented by the backend" do
|
data/lib/i18n/tests/defaults.rb
CHANGED
@@ -29,7 +29,7 @@ module I18n
|
|
29
29
|
end
|
30
30
|
|
31
31
|
test "defaults: given nil it returns nil" do
|
32
|
-
|
32
|
+
assert_nil I18n.t(:does_not_exist, :default => nil)
|
33
33
|
end
|
34
34
|
|
35
35
|
test "defaults: given an array of missing keys it raises a MissingTranslationData exception" do
|
data/lib/i18n/version.rb
CHANGED
@@ -68,6 +68,14 @@ class I18nBackendFallbacksTranslateTest < I18n::TestCase
|
|
68
68
|
assert_equal 'Default 6 Bars', I18n.t(:missing_foo, :locale => :'de-DE', :default => [:missing_bar, {:other => "Default %{count} Bars"}, "Default Bar"], :count => 6)
|
69
69
|
end
|
70
70
|
|
71
|
+
test "returns the default translation for a missing :de translation even when default is a String when fallback is disabled" do
|
72
|
+
assert_equal 'Default String', I18n.t(:foo, :locale => :de, :default => 'Default String', :fallback => false)
|
73
|
+
end
|
74
|
+
|
75
|
+
test "raises I18n::MissingTranslationData exception when fallback is disabled even when fallback translation exists" do
|
76
|
+
assert_raise(I18n::MissingTranslationData) { I18n.t(:foo, :locale => :de, :fallback => false, :raise => true) }
|
77
|
+
end
|
78
|
+
|
71
79
|
test "raises I18n::MissingTranslationData exception when no translation was found" do
|
72
80
|
assert_raise(I18n::MissingTranslationData) { I18n.t(:faa, :locale => :en, :raise => true) }
|
73
81
|
assert_raise(I18n::MissingTranslationData) { I18n.t(:faa, :locale => :de, :raise => true) }
|
@@ -195,4 +203,4 @@ class I18nBackendFallbacksExistsTest < I18n::TestCase
|
|
195
203
|
assert_equal false, I18n.exists?(:baz, :de)
|
196
204
|
assert_equal false, I18n.exists?(:bogus, :'de-DE')
|
197
205
|
end
|
198
|
-
end
|
206
|
+
end
|
data/test/i18n_test.rb
CHANGED
@@ -270,7 +270,7 @@ class I18nTest < I18n::TestCase
|
|
270
270
|
end
|
271
271
|
|
272
272
|
test "localize given nil and default returns default" do
|
273
|
-
|
273
|
+
assert_nil I18n.l(nil, :default => nil)
|
274
274
|
end
|
275
275
|
|
276
276
|
test "localize given an Object raises an I18n::ArgumentError" do
|
@@ -351,6 +351,10 @@ class I18nTest < I18n::TestCase
|
|
351
351
|
end
|
352
352
|
end
|
353
353
|
|
354
|
+
test "transliterate non-ASCII chars not in map with default replacement char" do
|
355
|
+
assert_equal "???", I18n.transliterate("日本語")
|
356
|
+
end
|
357
|
+
|
354
358
|
test "I18n.locale_available? returns true when the passed locale is available" do
|
355
359
|
I18n.available_locales = [:en, :de]
|
356
360
|
assert_equal true, I18n.locale_available?(:de)
|
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.8.
|
4
|
+
version: 0.8.1
|
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: 2017-
|
15
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: New wave Internationalization support for Ruby.
|
18
18
|
email: rails-i18n@googlegroups.com
|
@@ -23,17 +23,11 @@ files:
|
|
23
23
|
- MIT-LICENSE
|
24
24
|
- README.md
|
25
25
|
- gemfiles/Gemfile.rails-3.2.x
|
26
|
-
- gemfiles/Gemfile.rails-3.2.x.lock
|
27
26
|
- gemfiles/Gemfile.rails-4.0.x
|
28
|
-
- gemfiles/Gemfile.rails-4.0.x.lock
|
29
27
|
- gemfiles/Gemfile.rails-4.1.x
|
30
|
-
- gemfiles/Gemfile.rails-4.1.x.lock
|
31
28
|
- gemfiles/Gemfile.rails-4.2.x
|
32
|
-
- gemfiles/Gemfile.rails-4.2.x.lock
|
33
29
|
- gemfiles/Gemfile.rails-5.0.x
|
34
|
-
- gemfiles/Gemfile.rails-5.0.x.lock
|
35
30
|
- gemfiles/Gemfile.rails-master
|
36
|
-
- gemfiles/Gemfile.rails-master.lock
|
37
31
|
- lib/i18n.rb
|
38
32
|
- lib/i18n/backend.rb
|
39
33
|
- lib/i18n/backend/base.rb
|
@@ -1,32 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.8.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (3.2.21)
|
10
|
-
i18n (~> 0.6, >= 0.6.4)
|
11
|
-
multi_json (~> 1.0)
|
12
|
-
metaclass (0.0.4)
|
13
|
-
minitest (5.9.1)
|
14
|
-
mocha (1.1.0)
|
15
|
-
metaclass (~> 0.0.1)
|
16
|
-
multi_json (1.11.0)
|
17
|
-
rake (10.4.2)
|
18
|
-
test_declarative (0.0.5)
|
19
|
-
|
20
|
-
PLATFORMS
|
21
|
-
ruby
|
22
|
-
|
23
|
-
DEPENDENCIES
|
24
|
-
activesupport (~> 3.2.0)
|
25
|
-
i18n!
|
26
|
-
minitest
|
27
|
-
mocha
|
28
|
-
rake
|
29
|
-
test_declarative
|
30
|
-
|
31
|
-
BUNDLED WITH
|
32
|
-
1.13.7
|
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.8.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (4.0.13)
|
10
|
-
i18n (~> 0.6, >= 0.6.9)
|
11
|
-
minitest (~> 4.2)
|
12
|
-
multi_json (~> 1.3)
|
13
|
-
thread_safe (~> 0.1)
|
14
|
-
tzinfo (~> 0.3.37)
|
15
|
-
metaclass (0.0.4)
|
16
|
-
minitest (4.7.5)
|
17
|
-
mocha (1.1.0)
|
18
|
-
metaclass (~> 0.0.1)
|
19
|
-
multi_json (1.11.0)
|
20
|
-
rake (10.4.2)
|
21
|
-
test_declarative (0.0.5)
|
22
|
-
thread_safe (0.3.5)
|
23
|
-
tzinfo (0.3.43)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
activesupport (~> 4.0.0)
|
30
|
-
i18n!
|
31
|
-
minitest
|
32
|
-
mocha
|
33
|
-
rake
|
34
|
-
test_declarative
|
35
|
-
|
36
|
-
BUNDLED WITH
|
37
|
-
1.13.7
|
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.8.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (4.1.10)
|
10
|
-
i18n (~> 0.6, >= 0.6.9)
|
11
|
-
json (~> 1.7, >= 1.7.7)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
thread_safe (~> 0.1)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
json (1.8.2)
|
16
|
-
metaclass (0.0.4)
|
17
|
-
minitest (5.5.1)
|
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.5)
|
23
|
-
tzinfo (1.2.2)
|
24
|
-
thread_safe (~> 0.1)
|
25
|
-
|
26
|
-
PLATFORMS
|
27
|
-
ruby
|
28
|
-
|
29
|
-
DEPENDENCIES
|
30
|
-
activesupport (~> 4.1.0)
|
31
|
-
i18n!
|
32
|
-
minitest
|
33
|
-
mocha
|
34
|
-
rake
|
35
|
-
test_declarative
|
36
|
-
|
37
|
-
BUNDLED WITH
|
38
|
-
1.13.7
|
@@ -1,38 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.8.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (4.2.1)
|
10
|
-
i18n (~> 0.7)
|
11
|
-
json (~> 1.7, >= 1.7.7)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
-
tzinfo (~> 1.1)
|
15
|
-
json (1.8.2)
|
16
|
-
metaclass (0.0.4)
|
17
|
-
minitest (5.5.1)
|
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.5)
|
23
|
-
tzinfo (1.2.2)
|
24
|
-
thread_safe (~> 0.1)
|
25
|
-
|
26
|
-
PLATFORMS
|
27
|
-
ruby
|
28
|
-
|
29
|
-
DEPENDENCIES
|
30
|
-
activesupport (~> 4.2.0)
|
31
|
-
i18n!
|
32
|
-
minitest
|
33
|
-
mocha
|
34
|
-
rake
|
35
|
-
test_declarative
|
36
|
-
|
37
|
-
BUNDLED WITH
|
38
|
-
1.13.7
|
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
i18n (0.8.0.beta1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
activesupport (5.0.0.1)
|
10
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
-
i18n (~> 0.7)
|
12
|
-
minitest (~> 5.1)
|
13
|
-
tzinfo (~> 1.1)
|
14
|
-
concurrent-ruby (1.0.2)
|
15
|
-
metaclass (0.0.4)
|
16
|
-
minitest (5.9.1)
|
17
|
-
mocha (1.2.1)
|
18
|
-
metaclass (~> 0.0.1)
|
19
|
-
rake (11.3.0)
|
20
|
-
test_declarative (0.0.5)
|
21
|
-
thread_safe (0.3.5)
|
22
|
-
tzinfo (1.2.2)
|
23
|
-
thread_safe (~> 0.1)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
activesupport (~> 5.0.0)
|
30
|
-
i18n!
|
31
|
-
minitest
|
32
|
-
mocha
|
33
|
-
rake
|
34
|
-
test_declarative
|
35
|
-
|
36
|
-
BUNDLED WITH
|
37
|
-
1.13.7
|
@@ -1,43 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/rails/rails.git
|
3
|
-
revision: da23e125f8d755917b08f5cca1f7fe1ff38c8b7e
|
4
|
-
branch: master
|
5
|
-
specs:
|
6
|
-
activesupport (5.1.0.alpha)
|
7
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
8
|
-
i18n (~> 0.7)
|
9
|
-
minitest (~> 5.1)
|
10
|
-
tzinfo (~> 1.1)
|
11
|
-
|
12
|
-
PATH
|
13
|
-
remote: ..
|
14
|
-
specs:
|
15
|
-
i18n (0.8.0.beta1)
|
16
|
-
|
17
|
-
GEM
|
18
|
-
remote: https://rubygems.org/
|
19
|
-
specs:
|
20
|
-
concurrent-ruby (1.0.2)
|
21
|
-
metaclass (0.0.4)
|
22
|
-
minitest (5.5.1)
|
23
|
-
mocha (1.1.0)
|
24
|
-
metaclass (~> 0.0.1)
|
25
|
-
rake (10.4.2)
|
26
|
-
test_declarative (0.0.5)
|
27
|
-
thread_safe (0.3.5)
|
28
|
-
tzinfo (1.2.2)
|
29
|
-
thread_safe (~> 0.1)
|
30
|
-
|
31
|
-
PLATFORMS
|
32
|
-
ruby
|
33
|
-
|
34
|
-
DEPENDENCIES
|
35
|
-
activesupport!
|
36
|
-
i18n!
|
37
|
-
minitest
|
38
|
-
mocha
|
39
|
-
rake
|
40
|
-
test_declarative
|
41
|
-
|
42
|
-
BUNDLED WITH
|
43
|
-
1.13.7
|