i18n 0.8.4 → 0.8.5

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: 7aea28fdffb1b83ffc558cca097cb9ddd692a5e5
4
- data.tar.gz: 1143c46c544e1ca82f014f6995df8170f13d896d
3
+ metadata.gz: 29ba3d47b7f95d69e05c3ec152dedd933953a2c7
4
+ data.tar.gz: fd45bb60da662e967b26000f6e91905cb79f3a6b
5
5
  SHA512:
6
- metadata.gz: 835ea057465196d791bba7a9d1affdf4d80e6ef4321fc08ff704571106d112eb3387cc757c8be8e115d9ffcfff808f38b9d05740ce68b63c873a7bbe4eb21646
7
- data.tar.gz: 4ccba735b7f85e8b755d8f9308c36d2c31d6aabb7051a162c917997e47cfd016b3ffddda27de5a4262165c6cb602be45f0e32c30686b8ee5f067f387faf36056
6
+ metadata.gz: 5e087614ea6735a65e689f90ea7ad4689fe61f8daff455687c3dcb5b4d778b78afe1f674602018681c1ac0ca36470c03fba9663166ed03694504ba8bad154fcb
7
+ data.tar.gz: 1499ab0e51622e8663db528cc7a18718175a965c655302a34bdfc48e16137535c3b959b1f79a73b129211a2ff8f5c0948b8c72a7486c94806b6f08402554b84a
@@ -136,14 +136,14 @@ module I18n
136
136
  # - It will pick the :other subkey otherwise.
137
137
  # - It will pick the :zero subkey in the special case where count is
138
138
  # equal to 0 and there is a :zero subkey present. This behaviour is
139
- # not stand with regards to the CLDR pluralization rules.
139
+ # not standard with regards to the CLDR pluralization rules.
140
140
  # Other backends can implement more flexible or complex pluralization rules.
141
141
  def pluralize(locale, entry, count)
142
142
  return entry unless entry.is_a?(Hash) && count
143
143
 
144
144
  key = :zero if count == 0 && entry.has_key?(:zero)
145
145
  key ||= count == 1 ? :one : :other
146
- raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
146
+ raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
147
147
  entry[key]
148
148
  end
149
149
 
@@ -36,11 +36,11 @@ module I18n
36
36
  # it is evaluated last after all the fallback locales have been tried.
37
37
  def translate(locale, key, options = {})
38
38
  return super unless options.fetch(:fallback, true)
39
- return super if (@fallback_locked ||= false)
39
+ return super if options[:fallback_in_progress]
40
40
  default = extract_non_symbol_default!(options) if options[:default]
41
41
 
42
42
  begin
43
- @fallback_locked = true
43
+ options[:fallback_in_progress] = true
44
44
  I18n.fallbacks[locale].each do |fallback|
45
45
  begin
46
46
  catch(:exception) do
@@ -52,7 +52,7 @@ module I18n
52
52
  end
53
53
  end
54
54
  ensure
55
- @fallback_locked = false
55
+ options.delete(:fallback_in_progress)
56
56
  end
57
57
 
58
58
  return super(locale, nil, options.merge(:default => default)) if default
@@ -32,7 +32,7 @@ module I18n
32
32
  pluralizer = pluralizer(locale)
33
33
  if pluralizer.respond_to?(:call)
34
34
  key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count)
35
- raise InvalidPluralizationData.new(entry, count) unless entry.has_key?(key)
35
+ raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
36
36
  entry[key]
37
37
  else
38
38
  super
@@ -71,10 +71,10 @@ module I18n
71
71
  end
72
72
 
73
73
  class InvalidPluralizationData < ArgumentError
74
- attr_reader :entry, :count
75
- def initialize(entry, count)
76
- @entry, @count = entry, count
77
- super "translation data #{entry.inspect} can not be used with :count => #{count}"
74
+ attr_reader :entry, :count, :key
75
+ def initialize(entry, count, key)
76
+ @entry, @count, @key = entry, count, key
77
+ super "translation data #{entry.inspect} can not be used with :count => #{count}. key '#{key}' is missing."
78
78
  end
79
79
  end
80
80
 
@@ -72,7 +72,7 @@ module I18n
72
72
  when ::Date
73
73
  arg.strftime('%a, %d %b %Y')
74
74
  when Hash
75
- arg.delete(:fallback)
75
+ arg.delete(:fallback_in_progress)
76
76
  arg.inspect
77
77
  else
78
78
  arg.inspect
@@ -48,7 +48,7 @@ module I18n
48
48
 
49
49
 
50
50
  def self.filter_args(*args)
51
- args.map {|arg| arg.delete(:fallback) if arg.is_a?(Hash) ; arg }.inspect
51
+ args.map {|arg| arg.delete(:fallback_in_progress) if arg.is_a?(Hash) ; arg }.inspect
52
52
  end
53
53
  end
54
54
  end
@@ -1,3 +1,3 @@
1
1
  module I18n
2
- VERSION = "0.8.4"
2
+ VERSION = "0.8.5"
3
3
  end
@@ -32,16 +32,19 @@ class I18nExceptionsTest < I18n::TestCase
32
32
  end
33
33
  end
34
34
 
35
- test "InvalidPluralizationData stores entry and count" do
35
+ test "InvalidPluralizationData stores entry, count and key" do
36
36
  force_invalid_pluralization_data do |exception|
37
- assert_equal [:bar], exception.entry
37
+ assert_equal({:other => "bar"}, exception.entry)
38
38
  assert_equal 1, exception.count
39
+ assert_equal :one, exception.key
39
40
  end
40
41
  end
41
42
 
42
- test "InvalidPluralizationData message contains count and data" do
43
+ test "InvalidPluralizationData message contains count, data and missing key" do
43
44
  force_invalid_pluralization_data do |exception|
44
- assert_equal 'translation data [:bar] can not be used with :count => 1', exception.message
45
+ assert_match '1', exception.message
46
+ assert_match '{:other=>"bar"}', exception.message
47
+ assert_match 'one', exception.message
45
48
  end
46
49
  end
47
50
 
@@ -71,7 +74,7 @@ class I18nExceptionsTest < I18n::TestCase
71
74
  assert_equal 'reserved key :scope used in "%{scope}"', exception.message
72
75
  end
73
76
  end
74
-
77
+
75
78
  test "MissingTranslationData#new can be initialized with just two arguments" do
76
79
  assert I18n::MissingTranslationData.new('en', 'key')
77
80
  end
@@ -92,7 +95,7 @@ class I18nExceptionsTest < I18n::TestCase
92
95
  end
93
96
 
94
97
  def force_invalid_pluralization_data
95
- store_translations('de', :foo => [:bar])
98
+ store_translations('de', :foo => { :other => 'bar' })
96
99
  I18n.translate(:foo, :count => 1, :locale => :de)
97
100
  rescue I18n::ArgumentError => e
98
101
  block_given? ? yield(e) : raise(e)
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
4
+ version: 0.8.5
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-05-31 00:00:00.000000000 Z
15
+ date: 2017-07-08 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.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activesupport (3.2.22.5)
10
- i18n (~> 0.6, >= 0.6.4)
11
- multi_json (~> 1.0)
12
- metaclass (0.0.4)
13
- minitest (5.10.1)
14
- mocha (1.2.1)
15
- metaclass (~> 0.0.1)
16
- multi_json (1.12.1)
17
- rake (12.0.0)
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.14.6
@@ -1,37 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- i18n (0.8.2)
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.2.1)
18
- metaclass (~> 0.0.1)
19
- multi_json (1.12.1)
20
- rake (12.0.0)
21
- test_declarative (0.0.5)
22
- thread_safe (0.3.6)
23
- tzinfo (0.3.53)
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.14.6
@@ -1,38 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- i18n (0.8.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activesupport (4.1.16)
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.6)
16
- metaclass (0.0.4)
17
- minitest (5.10.1)
18
- mocha (1.2.1)
19
- metaclass (~> 0.0.1)
20
- rake (12.0.0)
21
- test_declarative (0.0.5)
22
- thread_safe (0.3.6)
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.14.6
@@ -1,36 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- i18n (0.8.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activesupport (4.2.8)
10
- i18n (~> 0.7)
11
- minitest (~> 5.1)
12
- thread_safe (~> 0.3, >= 0.3.4)
13
- tzinfo (~> 1.1)
14
- metaclass (0.0.4)
15
- minitest (5.10.1)
16
- mocha (1.2.1)
17
- metaclass (~> 0.0.1)
18
- rake (12.0.0)
19
- test_declarative (0.0.5)
20
- thread_safe (0.3.6)
21
- tzinfo (1.2.2)
22
- thread_safe (~> 0.1)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- activesupport (~> 4.2.0)
29
- i18n!
30
- minitest
31
- mocha
32
- rake
33
- test_declarative
34
-
35
- BUNDLED WITH
36
- 1.14.6
@@ -1,37 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- i18n (0.8.2)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- activesupport (5.0.2)
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.5)
15
- metaclass (0.0.4)
16
- minitest (5.10.1)
17
- mocha (1.2.1)
18
- metaclass (~> 0.0.1)
19
- rake (12.0.0)
20
- test_declarative (0.0.5)
21
- thread_safe (0.3.6)
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.14.6
@@ -1,43 +0,0 @@
1
- GIT
2
- remote: git://github.com/rails/rails.git
3
- revision: 49aa974ec8b15721d53b3b6abea88bd6ba433a68
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.2)
16
-
17
- GEM
18
- remote: https://rubygems.org/
19
- specs:
20
- concurrent-ruby (1.0.5)
21
- metaclass (0.0.4)
22
- minitest (5.10.1)
23
- mocha (1.2.1)
24
- metaclass (~> 0.0.1)
25
- rake (12.0.0)
26
- test_declarative (0.0.5)
27
- thread_safe (0.3.6)
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.14.6