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
- h1. Ruby I18n
1
+ # Ruby I18n
2
2
 
3
- !https://secure.travis-ci.org/svenfuchs/i18n.png?branch=master(Build Status)!:http://travis-ci.org/svenfuchs/i18n
3
+ [![Build Status](https://api.travis-ci.org/svenfuchs/i18n.svg?branch=master)](https://travis-ci.org/svenfuchs/i18n)
4
4
 
5
5
  Ruby Internationalization and localization solution.
6
6
 
@@ -31,37 +31,37 @@ Alternative backends:
31
31
  * ActiveRecord (optionally: ActiveRecord::Missing and ActiveRecord::StoreProcs)
32
32
  * KeyValue (uses active_support/json and cannot store procs)
33
33
 
34
- For more information and lots of resources see: "http://ruby-i18n.org/wiki":http://ruby-i18n.org/wiki
34
+ For more information and lots of resources see: [http://ruby-i18n.org/wiki](http://ruby-i18n.org/wiki)
35
35
 
36
- h2. Installation
36
+ ## Installation
37
37
 
38
38
  gem install i18n
39
39
 
40
- h4. Rails version warning
40
+ #### Rails version warning
41
41
 
42
- On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue "20":http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended.
42
+ On Rails < 2.3.6 the method I18n.localize will fail with MissingInterpolationArgument (issue [20](http://github.com/svenfuchs/i18n/issues/issue/20). Upgrade to Rails 2.3.6 or higher (2.3.8 preferably) is recommended.
43
43
 
44
- h3. Installation on Rails < 2.3.5 (deprecated)
44
+ ### Installation on Rails < 2.3.5 (deprecated)
45
45
 
46
46
  Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is an unpacked
47
- gem inside of active_support/lib/vendor which gets loaded unless gem 'i18n', '~> 0.1.3'.
48
- This requirement is relaxed in "6da03653":http://github.com/rails/rails/commit/6da03653
47
+ gem inside of active_support/lib/vendor which gets loaded unless `gem 'i18n', '~> 0.1.3'`.
48
+ This requirement is relaxed in [6da03653](http://github.com/rails/rails/commit/6da03653)
49
49
 
50
50
  The new i18n gem can be loaded from vendor/plugins like this:
51
51
 
52
- <pre>
53
- def reload_i18n!
54
- raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
52
+ ```
53
+ def reload_i18n!
54
+ raise "Move to i18n version 0.2.0 or greater" if Rails.version > "2.3.4"
55
55
 
56
- $:.grep(/i18n/).each { |path| $:.delete(path) }
57
- I18n::Backend.send :remove_const, "Simple"
58
- $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
59
- end
60
- </pre>
56
+ $:.grep(/i18n/).each { |path| $:.delete(path) }
57
+ I18n::Backend.send :remove_const, "Simple"
58
+ $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
59
+ end
60
+ ```
61
61
 
62
62
  Then you can `reload_i18n!` inside an i18n initializer.
63
63
 
64
- h2. Tests
64
+ ## Tests
65
65
 
66
66
  You can run tests both with
67
67
 
@@ -85,21 +85,21 @@ as test methods) in test cases with different setups.
85
85
  You can find the test cases that enforce the API in test/api. And you can find
86
86
  the API definition test methods in test/api/tests.
87
87
 
88
- All other test cases (e.g. as defined in test/backend, test/core\_ext) etc.
88
+ All other test cases (e.g. as defined in test/backend, test/core_ext) etc.
89
89
  follow the usual test setup and should be easy to grok.
90
90
 
91
- h2. Authors
91
+ ## Authors
92
92
 
93
- * "Sven Fuchs":http://www.artweb-design.de
94
- * "Joshua Harvey":http://www.workingwithrails.com/person/759-joshua-harvey
95
- * "Stephan Soller":http://www.arkanis-development.de
96
- * "Saimon Moore":http://saimonmoore.net
97
- * "Matt Aimonetti":http://railsontherun.com
93
+ * [Sven Fuchs](http://www.artweb-design.de)
94
+ * [Joshua Harvey](http://www.workingwithrails.com/person/759-joshua-harvey)
95
+ * [Stephan Soller](http://www.arkanis-development.de)
96
+ * [Saimon Moore](http://saimonmoore.net)
97
+ * [Matt Aimonetti](http://railsontherun.com)
98
98
 
99
- h2. Contributors
99
+ ## Contributors
100
100
 
101
101
  http://github.com/svenfuchs/i18n/contributors
102
102
 
103
- h2. License
103
+ ## License
104
104
 
105
105
  MIT License. See the included MIT-LICENSE file.
@@ -1,9 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec :path => '..'
4
+
3
5
  gem 'activesupport', '~> 2.3'
4
- gem 'sqlite3-ruby'
5
6
  gem 'mocha'
6
7
  gem 'test_declarative'
7
8
  gem 'rufus-tokyo'
8
9
  gem 'ffi'
9
-
10
+ gem 'rake'
11
+ gem 'yajl-ruby'
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (2.3.18)
10
+ ffi (1.9.3)
11
+ metaclass (0.0.4)
12
+ mocha (1.0.0)
13
+ metaclass (~> 0.0.1)
14
+ rake (10.3.1)
15
+ rufus-tokyo (1.0.7)
16
+ test_declarative (0.0.5)
17
+ yajl-ruby (1.2.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ activesupport (~> 2.3)
24
+ ffi
25
+ i18n!
26
+ mocha
27
+ rake
28
+ rufus-tokyo
29
+ test_declarative
30
+ yajl-ruby
@@ -1,9 +1,11 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec :path => '..'
4
+
3
5
  gem 'activesupport', '~> 3.0.0'
4
- gem 'sqlite3-ruby'
5
6
  gem 'mocha'
6
7
  gem 'test_declarative'
7
8
  gem 'rufus-tokyo'
8
9
  gem 'ffi'
9
-
10
+ gem 'rake'
11
+ gem 'yajl-ruby'
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (3.0.20)
10
+ ffi (1.9.3)
11
+ metaclass (0.0.4)
12
+ mocha (1.0.0)
13
+ metaclass (~> 0.0.1)
14
+ rake (10.3.1)
15
+ rufus-tokyo (1.0.7)
16
+ test_declarative (0.0.5)
17
+ yajl-ruby (1.2.0)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ activesupport (~> 3.0.0)
24
+ ffi
25
+ i18n!
26
+ mocha
27
+ rake
28
+ rufus-tokyo
29
+ test_declarative
30
+ yajl-ruby
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem 'activesupport', '~> 3.1.0'
6
+ gem 'mocha'
7
+ gem 'test_declarative'
8
+ gem 'rufus-tokyo'
9
+ gem 'ffi'
10
+ gem 'rake'
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (3.1.12)
10
+ multi_json (~> 1.0)
11
+ ffi (1.9.3)
12
+ metaclass (0.0.4)
13
+ mocha (1.0.0)
14
+ metaclass (~> 0.0.1)
15
+ multi_json (1.10.0)
16
+ rake (10.3.1)
17
+ rufus-tokyo (1.0.7)
18
+ test_declarative (0.0.5)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ activesupport (~> 3.1.0)
25
+ ffi
26
+ i18n!
27
+ mocha
28
+ rake
29
+ rufus-tokyo
30
+ test_declarative
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem 'activesupport', '~> 3.2.0'
6
+ gem 'mocha'
7
+ gem 'test_declarative'
8
+ gem 'rufus-tokyo'
9
+ gem 'ffi'
10
+ gem 'rake'
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (3.2.18)
10
+ i18n (~> 0.6, >= 0.6.4)
11
+ multi_json (~> 1.0)
12
+ ffi (1.9.3)
13
+ metaclass (0.0.4)
14
+ mocha (1.0.0)
15
+ metaclass (~> 0.0.1)
16
+ multi_json (1.10.0)
17
+ rake (10.3.1)
18
+ rufus-tokyo (1.0.7)
19
+ test_declarative (0.0.5)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ activesupport (~> 3.2.0)
26
+ ffi
27
+ i18n!
28
+ mocha
29
+ rake
30
+ rufus-tokyo
31
+ test_declarative
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem 'activesupport', '~> 4.0.0'
6
+ gem 'mocha'
7
+ gem 'test_declarative'
8
+ gem 'rufus-tokyo'
9
+ gem 'ffi'
10
+ gem 'rake'
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.0.5)
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
+ ffi (1.9.3)
16
+ metaclass (0.0.4)
17
+ minitest (4.7.5)
18
+ mocha (1.0.0)
19
+ metaclass (~> 0.0.1)
20
+ multi_json (1.10.0)
21
+ rake (10.3.1)
22
+ rufus-tokyo (1.0.7)
23
+ test_declarative (0.0.5)
24
+ thread_safe (0.3.3)
25
+ tzinfo (0.3.39)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ activesupport (~> 4.0.0)
32
+ ffi
33
+ i18n!
34
+ mocha
35
+ rake
36
+ rufus-tokyo
37
+ test_declarative
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem 'activesupport', '~> 4.1.0'
6
+ gem 'mocha'
7
+ gem 'test_declarative'
8
+ gem 'rufus-tokyo'
9
+ gem 'ffi'
10
+ gem 'rake'
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ i18n (0.6.11)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ activesupport (4.1.1)
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
+ ffi (1.9.3)
16
+ json (1.8.1)
17
+ metaclass (0.0.4)
18
+ minitest (5.3.3)
19
+ mocha (1.0.0)
20
+ metaclass (~> 0.0.1)
21
+ rake (10.3.1)
22
+ rufus-tokyo (1.0.7)
23
+ test_declarative (0.0.5)
24
+ thread_safe (0.3.3)
25
+ tzinfo (1.1.0)
26
+ thread_safe (~> 0.1)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ activesupport (~> 4.1.0)
33
+ ffi
34
+ i18n!
35
+ mocha
36
+ rake
37
+ rufus-tokyo
38
+ test_declarative
@@ -271,16 +271,13 @@ module I18n
271
271
  keys
272
272
  end
273
273
 
274
- # Returns true when the passed locale is in I18.available_locales.
275
- # Returns false otherwise.
276
- # Compare with Strings as `locale` may be coming from user input
274
+ # Returns true when the passed locale, which can be either a String or a
275
+ # Symbol, is in the list of available locales. Returns false otherwise.
277
276
  def locale_available?(locale)
278
- I18n.available_locales.map(&:to_s).include?(locale.to_s)
277
+ I18n.config.available_locales_set.include?(locale)
279
278
  end
280
279
 
281
- # Raises an InvalidLocale exception when the passed locale is not
282
- # included in I18n.available_locales.
283
- # Returns false otherwise
280
+ # Raises an InvalidLocale exception when the passed locale is not available.
284
281
  def enforce_available_locales!(locale)
285
282
  handle_enforce_available_locales_deprecation
286
283
 
@@ -358,8 +355,8 @@ module I18n
358
355
  end
359
356
 
360
357
  def handle_enforce_available_locales_deprecation
361
- if config.enforce_available_locales.nil? && !@unenforced_available_locales_deprecation
362
- $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message."
358
+ if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation)
359
+ $stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message."
363
360
  @unenforced_available_locales_deprecation = true
364
361
  end
365
362
  end
@@ -1,6 +1,6 @@
1
1
  require 'yaml'
2
2
  require 'i18n/core_ext/hash'
3
- require 'i18n/core_ext/kernel/surpress_warnings'
3
+ require 'i18n/core_ext/kernel/suppress_warnings'
4
4
 
5
5
  module I18n
6
6
  module Backend
@@ -40,9 +40,13 @@ module I18n
40
40
 
41
41
  options[:fallback] = true
42
42
  I18n.fallbacks[locale].each do |fallback|
43
- catch(:exception) do
44
- result = super(fallback, key, options)
45
- return result unless result.nil?
43
+ begin
44
+ catch(:exception) do
45
+ result = super(fallback, key, options)
46
+ return result unless result.nil?
47
+ end
48
+ rescue I18n::InvalidLocale
49
+ # we do nothing when the locale is invalid, as this is a fallback anyways.
46
50
  end
47
51
  end
48
52
  options.delete(:fallback)
@@ -41,10 +41,19 @@ module I18n
41
41
  @@available_locales || backend.available_locales
42
42
  end
43
43
 
44
+ # Caches the available locales list as both strings and symbols in a Set, so
45
+ # that we can have faster lookups to do the available locales enforce check.
46
+ def available_locales_set #:nodoc:
47
+ @@available_locales_set ||= available_locales.inject(Set.new) do |set, locale|
48
+ set << locale.to_s << locale.to_sym
49
+ end
50
+ end
51
+
44
52
  # Sets the available locales.
45
53
  def available_locales=(locales)
46
54
  @@available_locales = Array(locales).map { |locale| locale.to_sym }
47
55
  @@available_locales = nil if @@available_locales.empty?
56
+ @@available_locales_set = nil
48
57
  end
49
58
 
50
59
  # Returns the current default scope separator. Defaults to '.'