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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b6433e5959dd59f7cbc749fe2cf4ab553282d59
4
- data.tar.gz: 56e4232a2598aacbfde0803866c8dbf0f7b65715
3
+ metadata.gz: 233c2489c16a63d11d29c05a13517dd6674e52ce
4
+ data.tar.gz: b55ebffc18d9e3c9f75a54175858031e8f57d8d6
5
5
  SHA512:
6
- metadata.gz: 9f853f9dbcaf818c62134260296b9daad5885c5e68c5cacf87e13d5526d41ab982ff5387c9037d988b97bfec87b5854666088683157979af7dabcbf21f7e9714
7
- data.tar.gz: 2baa498d60d117129803c04336c7f1bc77d11a497890d2e68035bfe080d5b8827b52d7f04973339e90d9fc80e8025ae480b8e5f32f111465e523c551dffcee63
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 if options[:fallback]
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
- options[:fallback] = true
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
- options.delete(:fallback)
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 = DEFAULT_REPLACEMENT_CHAR)
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
@@ -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.expects(:available_locales).twice
41
- assert_equal I18n.available_locales, I18n.available_locales
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
@@ -29,7 +29,7 @@ module I18n
29
29
  end
30
30
 
31
31
  test "defaults: given nil it returns nil" do
32
- assert_equal nil, I18n.t(:does_not_exist, :default => nil)
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
@@ -1,3 +1,3 @@
1
1
  module I18n
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -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
@@ -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
- assert_equal nil, I18n.l(nil, :default => nil)
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.0
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-01-31 00:00:00.000000000 Z
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