i18n 0.6.9 → 0.6.11

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.

Files changed (59) hide show
  1. data/{README.textile → README.md} +27 -27
  2. data/{ci → gemfiles}/Gemfile.rails-2.3.x +4 -2
  3. data/gemfiles/Gemfile.rails-2.3.x.lock +30 -0
  4. data/{ci/Gemfile.rails-3.x → gemfiles/Gemfile.rails-3.0.x} +4 -2
  5. data/gemfiles/Gemfile.rails-3.0.x.lock +30 -0
  6. data/gemfiles/Gemfile.rails-3.1.x +10 -0
  7. data/gemfiles/Gemfile.rails-3.1.x.lock +30 -0
  8. data/gemfiles/Gemfile.rails-3.2.x +10 -0
  9. data/gemfiles/Gemfile.rails-3.2.x.lock +31 -0
  10. data/gemfiles/Gemfile.rails-4.0.x +10 -0
  11. data/gemfiles/Gemfile.rails-4.0.x.lock +37 -0
  12. data/gemfiles/Gemfile.rails-4.1.x +10 -0
  13. data/gemfiles/Gemfile.rails-4.1.x.lock +38 -0
  14. data/lib/i18n.rb +6 -9
  15. data/lib/i18n/backend/base.rb +1 -1
  16. data/lib/i18n/backend/fallbacks.rb +7 -3
  17. data/lib/i18n/config.rb +9 -0
  18. data/lib/i18n/core_ext/kernel/suppress_warnings.rb +8 -0
  19. data/lib/i18n/exceptions.rb +1 -1
  20. data/lib/i18n/version.rb +1 -1
  21. data/test/api/all_features_test.rb +1 -1
  22. data/test/api/cascade_test.rb +1 -1
  23. data/test/api/chain_test.rb +1 -1
  24. data/test/api/fallbacks_test.rb +1 -1
  25. data/test/api/key_value_test.rb +2 -2
  26. data/test/api/memoize_test.rb +3 -3
  27. data/test/api/override_test.rb +1 -6
  28. data/test/api/pluralization_test.rb +1 -1
  29. data/test/api/simple_test.rb +1 -1
  30. data/test/backend/cache_test.rb +1 -1
  31. data/test/backend/cascade_test.rb +1 -1
  32. data/test/backend/chain_test.rb +1 -1
  33. data/test/backend/exceptions_test.rb +1 -1
  34. data/test/backend/fallbacks_test.rb +24 -3
  35. data/test/backend/interpolation_compiler_test.rb +4 -5
  36. data/test/backend/key_value_test.rb +2 -2
  37. data/test/backend/metadata_test.rb +1 -1
  38. data/test/backend/pluralization_test.rb +1 -1
  39. data/test/backend/simple_test.rb +6 -6
  40. data/test/backend/transliterator_test.rb +1 -1
  41. data/test/core_ext/hash_test.rb +1 -1
  42. data/test/core_ext/string/interpolate_test.rb +1 -1
  43. data/test/gettext/api_test.rb +1 -1
  44. data/test/gettext/backend_test.rb +1 -1
  45. data/test/i18n/exceptions_test.rb +6 -6
  46. data/test/i18n/interpolate_test.rb +2 -2
  47. data/test/i18n/load_path_test.rb +1 -1
  48. data/test/i18n_test.rb +21 -4
  49. data/test/locale/fallbacks_test.rb +2 -2
  50. data/test/locale/tag/rfc4646_test.rb +3 -3
  51. data/test/locale/tag/simple_test.rb +1 -1
  52. data/test/run_all.rb +12 -13
  53. data/test/test_helper.rb +40 -20
  54. metadata +34 -106
  55. data/ci/Gemfile.no-rails +0 -5
  56. data/ci/Gemfile.no-rails.lock +0 -14
  57. data/ci/Gemfile.rails-2.3.x.lock +0 -23
  58. data/ci/Gemfile.rails-3.x.lock +0 -23
  59. data/lib/i18n/core_ext/kernel/surpress_warnings.rb +0 -9
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class I18nLoadPathTest < Test::Unit::TestCase
3
+ class I18nLoadPathTest < I18n::TestCase
4
4
  def setup
5
5
  I18n.locale = :en
6
6
  I18n.backend = I18n::Backend::Simple.new
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require 'test_helper'
3
3
 
4
- class I18nTest < Test::Unit::TestCase
4
+ class I18nTest < I18n::TestCase
5
5
  def setup
6
- I18n.backend.store_translations(:'en', :currency => { :format => { :separator => '.', :delimiter => ',', } })
7
- I18n.backend.store_translations(:'nl', :currency => { :format => { :separator => ',', :delimiter => '.', } })
6
+ store_translations(:en, :currency => { :format => { :separator => '.', :delimiter => ',', } })
7
+ store_translations(:nl, :currency => { :format => { :separator => ',', :delimiter => '.', } })
8
8
  end
9
9
 
10
10
  test "exposes its VERSION constant" do
@@ -56,7 +56,7 @@ class I18nTest < Test::Unit::TestCase
56
56
  assert_equal :de, Thread.current[:i18n_config].locale
57
57
  I18n.locale = :en
58
58
  end
59
-
59
+
60
60
  test "raises an I18n::InvalidLocale exception when setting an unavailable locale" do
61
61
  begin
62
62
  I18n.config.enforce_available_locales = true
@@ -215,6 +215,23 @@ class I18nTest < Test::Unit::TestCase
215
215
  end
216
216
  end
217
217
 
218
+ test "available_locales can be replaced at runtime" do
219
+ begin
220
+ I18n.config.enforce_available_locales = true
221
+ assert_raise(I18n::InvalidLocale) { I18n.t(:foo, :locale => 'klingon') }
222
+ old_locales, I18n.config.available_locales = I18n.config.available_locales, [:klingon]
223
+ I18n.t(:foo, :locale => 'klingon')
224
+ ensure
225
+ I18n.config.enforce_available_locales = false
226
+ I18n.config.available_locales = old_locales
227
+ end
228
+ end
229
+
230
+ test "available_locales_set should return a set" do
231
+ assert_equal Set, I18n.config.available_locales_set.class
232
+ assert_equal I18n.config.available_locales.size * 2, I18n.config.available_locales_set.size
233
+ end
234
+
218
235
  test "exists? given an existing key will return true" do
219
236
  assert_equal true, I18n.exists?(:currency)
220
237
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  include I18n::Locale
4
4
 
5
- class I18nFallbacksDefaultsTest < Test::Unit::TestCase
5
+ class I18nFallbacksDefaultsTest < I18n::TestCase
6
6
  def teardown
7
7
  I18n.default_locale = :en
8
8
  end
@@ -26,7 +26,7 @@ class I18nFallbacksDefaultsTest < Test::Unit::TestCase
26
26
  end
27
27
  end
28
28
 
29
- class I18nFallbacksComputationTest < Test::Unit::TestCase
29
+ class I18nFallbacksComputationTest < I18n::TestCase
30
30
  def setup
31
31
  @fallbacks = Fallbacks.new(:'en-US')
32
32
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'test_helper'
3
3
 
4
- class I18nLocaleTagRfc4646ParserTest < Test::Unit::TestCase
4
+ class I18nLocaleTagRfc4646ParserTest < I18n::TestCase
5
5
  include I18n::Locale
6
6
 
7
7
  test "Rfc4646::Parser given a valid tag 'de' returns an array of subtags" do
@@ -31,7 +31,7 @@ end
31
31
 
32
32
  # Tag for the locale 'de-Latn-DE-Variant-a-ext-x-phonebk-i-klingon'
33
33
 
34
- class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
34
+ class I18nLocaleTagSubtagsTest < I18n::TestCase
35
35
  include I18n::Locale
36
36
 
37
37
  def setup
@@ -78,7 +78,7 @@ end
78
78
 
79
79
  # Tag inheritance
80
80
 
81
- class I18nLocaleTagSubtagsTest < Test::Unit::TestCase
81
+ class I18nLocaleTagSubtagsTest < I18n::TestCase
82
82
  test "#parent returns 'de-Latn-DE-variant-a-ext-x-phonebk' as the parent of 'de-Latn-DE-variant-a-ext-x-phonebk-i-klingon'" do
83
83
  tag = Tag::Rfc4646.new(*%w(de Latn DE variant a-ext x-phonebk i-klingon))
84
84
  assert_equal 'de-Latn-DE-variant-a-ext-x-phonebk', tag.parent.to_s
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'test_helper'
3
3
 
4
- class I18nLocaleTagSimpleTest < Test::Unit::TestCase
4
+ class I18nLocaleTagSimpleTest < I18n::TestCase
5
5
  include I18n::Locale
6
6
 
7
7
  test "returns 'de' as the language subtag in lowercase" do
@@ -1,21 +1,20 @@
1
1
  def bundle_check
2
- `bundle check` == "The Gemfile's dependencies are satisfied\n"
2
+ `bundle check` == "Resolving dependencies...\nThe Gemfile's dependencies are satisfied\n"
3
3
  end
4
4
 
5
- command = 'ruby -w -Ilib -Itest test/all.rb'
6
- gemfiles = %w(ci/Gemfile.rails-3.x ci/Gemfile.rails-2.3.x ci/Gemfile.no-rails)
5
+ def execute(command)
6
+ puts command
7
+ system command
8
+ end
7
9
 
8
- results = gemfiles.map do |gemfile|
9
- puts "BUNDLE_GEMFILE=#{gemfile}"
10
- ENV['BUNDLE_GEMFILE'] = gemfile
10
+ gemfiles = %w(Gemfile) + Dir['gemfiles/Gemfile*'].reject { |f| f.end_with?('.lock') }
11
11
 
12
- unless bundle_check
13
- puts "bundle install"
14
- system('bundle install')
15
- end
12
+ results = gemfiles.map do |gemfile|
13
+ puts "\nBUNDLE_GEMFILE=#{gemfile}"
14
+ ENV['BUNDLE_GEMFILE'] = File.expand_path("../../#{gemfile}", __FILE__)
16
15
 
17
- puts command
18
- system('ruby -w -Ilib -Itest test/all.rb')
16
+ execute 'bundle install' unless bundle_check
17
+ execute 'bundle exec ruby -w -Ilib -Itest test/all.rb'
19
18
  end
20
19
 
21
- exit(results.inject(true) { |a, b| a && b })
20
+ exit results.all?
@@ -1,7 +1,25 @@
1
1
  $KCODE = 'u' if RUBY_VERSION <= '1.9'
2
2
 
3
3
  require 'rubygems'
4
- require 'test/unit'
4
+
5
+ # Use minitest if we can, otherwise fallback to test-unit.
6
+ begin
7
+ require 'minitest/autorun'
8
+ TEST_CASE = defined?(Minitest::Test) ? Minitest::Test : MiniTest::Unit::TestCase
9
+
10
+ # TODO: Remove these aliases and update tests accordingly.
11
+ class TEST_CASE
12
+ alias :assert_raise :assert_raises
13
+ alias :assert_not_equal :refute_equal
14
+
15
+ def assert_nothing_raised(*args)
16
+ yield
17
+ end
18
+ end
19
+ rescue LoadError
20
+ require 'test/unit'
21
+ TEST_CASE = Test::Unit::TestCase
22
+ end
5
23
 
6
24
  # Do not load the i18n gem from libraries like active_support.
7
25
  #
@@ -14,25 +32,41 @@ end
14
32
 
15
33
  require 'bundler/setup'
16
34
  require 'i18n'
17
- require 'mocha'
35
+ require 'mocha/setup'
18
36
  require 'test_declarative'
19
37
 
20
- class Test::Unit::TestCase
38
+ class I18n::TestCase < TEST_CASE
39
+ def self.setup_rufus_tokyo
40
+ require 'rufus/tokyo'
41
+ rescue LoadError => e
42
+ puts "can't use KeyValue backend because: #{e.message}"
43
+ end
44
+
21
45
  def teardown
46
+ super
22
47
  I18n.locale = nil
23
48
  I18n.default_locale = :en
24
49
  I18n.load_path = []
25
50
  I18n.available_locales = nil
26
51
  I18n.backend = nil
52
+ I18n.enforce_available_locales = nil
27
53
  end
28
54
 
55
+ # Ignore Test::Unit::TestCase failing if the test case does not contain any
56
+ # test, otherwise it will blow up because of this base class.
57
+ #
58
+ # TODO: remove when test-unit is not used anymore.
59
+ def default_test
60
+ nil
61
+ end
62
+
63
+ protected
64
+
29
65
  def translations
30
66
  I18n.backend.instance_variable_get(:@translations)
31
67
  end
32
68
 
33
- def store_translations(*args)
34
- data = args.pop
35
- locale = args.pop || :en
69
+ def store_translations(locale, data)
36
70
  I18n.backend.store_translations(locale, data)
37
71
  end
38
72
 
@@ -40,17 +74,3 @@ class Test::Unit::TestCase
40
74
  File.dirname(__FILE__) + '/test_data/locales'
41
75
  end
42
76
  end
43
-
44
- module Kernel
45
- def setup_rufus_tokyo
46
- require 'rufus/tokyo'
47
- rescue LoadError => e
48
- puts "can't use KeyValue backend because: #{e.message}"
49
- end
50
- end
51
-
52
- Object.class_eval do
53
- def meta_class
54
- class << self; self; end
55
- end
56
- end unless Object.method_defined?(:meta_class)
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: i18n
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.11
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 9
10
- version: 0.6.9
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Sven Fuchs
14
9
  - Joshua Harvey
15
10
  - Matt Aimonetti
@@ -18,82 +13,26 @@ authors:
18
13
  autorequire:
19
14
  bindir: bin
20
15
  cert_chain: []
21
-
22
- date: 2013-12-03 00:00:00 Z
23
- dependencies:
24
- - !ruby/object:Gem::Dependency
25
- name: activesupport
26
- prerelease: false
27
- requirement: &id001 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- hash: 7
33
- segments:
34
- - 3
35
- - 0
36
- - 0
37
- version: 3.0.0
38
- type: :development
39
- version_requirements: *id001
40
- - !ruby/object:Gem::Dependency
41
- name: sqlite3
42
- prerelease: false
43
- requirement: &id002 !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- hash: 3
49
- segments:
50
- - 0
51
- version: "0"
52
- type: :development
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: mocha
56
- prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
66
- type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: test_declarative
70
- prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- type: :development
81
- version_requirements: *id004
16
+ date: 2014-07-09 00:00:00.000000000 Z
17
+ dependencies: []
82
18
  description: New wave Internationalization support for Ruby.
83
19
  email: rails-i18n@googlegroups.com
84
20
  executables: []
85
-
86
21
  extensions: []
87
-
88
22
  extra_rdoc_files: []
89
-
90
- files:
91
- - ci/Gemfile.no-rails
92
- - ci/Gemfile.no-rails.lock
93
- - ci/Gemfile.rails-2.3.x
94
- - ci/Gemfile.rails-2.3.x.lock
95
- - ci/Gemfile.rails-3.x
96
- - ci/Gemfile.rails-3.x.lock
23
+ files:
24
+ - gemfiles/Gemfile.rails-2.3.x
25
+ - gemfiles/Gemfile.rails-2.3.x.lock
26
+ - gemfiles/Gemfile.rails-3.0.x
27
+ - gemfiles/Gemfile.rails-3.0.x.lock
28
+ - gemfiles/Gemfile.rails-3.1.x
29
+ - gemfiles/Gemfile.rails-3.1.x.lock
30
+ - gemfiles/Gemfile.rails-3.2.x
31
+ - gemfiles/Gemfile.rails-3.2.x.lock
32
+ - gemfiles/Gemfile.rails-4.0.x
33
+ - gemfiles/Gemfile.rails-4.0.x.lock
34
+ - gemfiles/Gemfile.rails-4.1.x
35
+ - gemfiles/Gemfile.rails-4.1.x.lock
97
36
  - lib/i18n/backend/base.rb
98
37
  - lib/i18n/backend/cache.rb
99
38
  - lib/i18n/backend/cascade.rb
@@ -111,7 +50,7 @@ files:
111
50
  - lib/i18n/backend.rb
112
51
  - lib/i18n/config.rb
113
52
  - lib/i18n/core_ext/hash.rb
114
- - lib/i18n/core_ext/kernel/surpress_warnings.rb
53
+ - lib/i18n/core_ext/kernel/suppress_warnings.rb
115
54
  - lib/i18n/core_ext/string/interpolate.rb
116
55
  - lib/i18n/exceptions.rb
117
56
  - lib/i18n/gettext/helpers.rb
@@ -180,42 +119,31 @@ files:
180
119
  - test/test_data/locales/invalid/syntax.yml
181
120
  - test/test_data/locales/plurals.rb
182
121
  - test/test_helper.rb
183
- - README.textile
122
+ - README.md
184
123
  - MIT-LICENSE
185
124
  homepage: http://github.com/svenfuchs/i18n
186
- licenses:
125
+ licenses:
187
126
  - MIT
188
127
  post_install_message:
189
128
  rdoc_options: []
190
-
191
- require_paths:
129
+ require_paths:
192
130
  - lib
193
- required_ruby_version: !ruby/object:Gem::Requirement
131
+ required_ruby_version: !ruby/object:Gem::Requirement
194
132
  none: false
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- hash: 3
199
- segments:
200
- - 0
201
- version: "0"
202
- required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
138
  none: false
204
- requirements:
205
- - - ">="
206
- - !ruby/object:Gem::Version
207
- hash: 17
208
- segments:
209
- - 1
210
- - 3
211
- - 5
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
212
142
  version: 1.3.5
213
143
  requirements: []
214
-
215
- rubyforge_project: "[none]"
216
- rubygems_version: 1.8.6
144
+ rubyforge_project: ! '[none]'
145
+ rubygems_version: 1.8.23.2
217
146
  signing_key:
218
147
  specification_version: 3
219
148
  summary: New wave Internationalization support for Ruby
220
149
  test_files: []
221
-
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'mocha'
4
- gem 'test_declarative'
5
-
@@ -1,14 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- mocha (0.9.9)
5
- rake
6
- rake (0.8.7)
7
- test_declarative (0.0.4)
8
-
9
- PLATFORMS
10
- ruby
11
-
12
- DEPENDENCIES
13
- mocha
14
- test_declarative
@@ -1,23 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activesupport (2.3.10)
5
- ffi (0.6.3)
6
- rake (>= 0.8.7)
7
- mocha (0.9.9)
8
- rake
9
- rake (0.8.7)
10
- rufus-tokyo (1.0.7)
11
- sqlite3-ruby (1.3.2)
12
- test_declarative (0.0.4)
13
-
14
- PLATFORMS
15
- ruby
16
-
17
- DEPENDENCIES
18
- activesupport (~> 2.3)
19
- ffi
20
- mocha
21
- rufus-tokyo
22
- sqlite3-ruby
23
- test_declarative