i18n 1.8.3 → 1.8.11

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
  SHA256:
3
- metadata.gz: 461ee8866033d12fb5dd2daaa85703916b83ba58c225afd5bfe31e30c3231aa6
4
- data.tar.gz: 9bd10034e9629c3fb72c07974fef0b069047b269dbab165ecbd5b8c38c9c5567
3
+ metadata.gz: df354d130700e7c31886ac15782c2617d563dea021c586a9194b6494eadf3fde
4
+ data.tar.gz: 4b72e7eb10961f84491eb11c33a0434276d0d780a77141d5dedc484a4a9561b3
5
5
  SHA512:
6
- metadata.gz: feb783a73598b1ab9e319f5569d71b14c061816bdb8e7d887262fed6531ec0a3c77afa36a4257080bbc7a1ec5239963a08b2f37a3dd449db82f9e402c5f57fbc
7
- data.tar.gz: fdb2f914e53484a8cf925b71de1004a4d0c1bfa3da4b7d50bd14fcda1ab036ae12d773e692cbf85ade5e78906af24fcc05b22156e280a4615e26430f8929eb75
6
+ metadata.gz: bf3447b5b7173685131998523341716b2b20cb03d256be5c8b287ba1fc44ce1e9cca0ed80b58708b860b5e01fa58c04b4a059978f2d8d2ed59bafa7a9dd35550
7
+ data.tar.gz: ce81270e8fbc5937a6dea497c485583d4adb4c3295fb824797028f771e2ac54118db3df26d157f222a3b70821a80174b4d50f959fe7010490cfffd391572272d
@@ -240,7 +240,11 @@ module I18n
240
240
  # toplevel keys.
241
241
  def load_yml(filename)
242
242
  begin
243
- YAML.load_file(filename)
243
+ if YAML.respond_to?(:unsafe_load_file) # Psych 4.0 way
244
+ YAML.unsafe_load_file(filename)
245
+ else
246
+ YAML.load_file(filename)
247
+ end
244
248
  rescue TypeError, ScriptError, StandardError => e
245
249
  raise InvalidLocaleData.new(filename, e.inspect)
246
250
  end
@@ -17,11 +17,11 @@
17
17
  #
18
18
  # The cache_key implementation by default assumes you pass values that return
19
19
  # a valid key from #hash (see
20
- # http://www.ruby-doc.org/core/classes/Object.html#M000337). However, you can
20
+ # https://www.ruby-doc.org/core/classes/Object.html#M000337). However, you can
21
21
  # configure your own digest method via which responds to #hexdigest (see
22
- # http://ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html):
22
+ # https://ruby-doc.org/stdlib/libdoc/openssl/rdoc/OpenSSL/Digest.html):
23
23
  #
24
- # I18n.cache_key_digest = Digest::MD5.new
24
+ # I18n.cache_key_digest = OpenSSL::Digest::SHA256.new
25
25
  #
26
26
  # If you use a lambda as a default value in your translation like this:
27
27
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'digest/sha2'
3
+ require 'openssl'
4
4
 
5
5
  module I18n
6
6
  module Backend
@@ -19,7 +19,7 @@ module I18n
19
19
  key = I18n::Backend::Flatten.escape_default_separator(normalized_path(filename))
20
20
  old_mtime, old_digest = initialized && lookup(:i18n, key, :load_file)
21
21
  return if (mtime = File.mtime(filename).to_i) == old_mtime ||
22
- (digest = Digest::SHA2.file(filename).hexdigest) == old_digest
22
+ (digest = OpenSSL::Digest::SHA256.file(filename).hexdigest) == old_digest
23
23
  super
24
24
  store_translations(:i18n, load_file: { key => [mtime, digest] })
25
25
  end
@@ -16,11 +16,13 @@ module I18n
16
16
  # Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
17
17
  def fallbacks
18
18
  @@fallbacks ||= I18n::Locale::Fallbacks.new
19
+ Thread.current[:i18n_fallbacks] || @@fallbacks
19
20
  end
20
21
 
21
22
  # Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
22
23
  def fallbacks=(fallbacks)
23
- @@fallbacks = fallbacks
24
+ @@fallbacks = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks
25
+ Thread.current[:i18n_fallbacks] = @@fallbacks
24
26
  end
25
27
  end
26
28
 
@@ -47,7 +49,7 @@ module I18n
47
49
  catch(:exception) do
48
50
  result = super(fallback, key, fallback_options)
49
51
  unless result.nil?
50
- on_fallback(locale, fallback, key, options) if locale != fallback
52
+ on_fallback(locale, fallback, key, options) if locale.to_s != fallback.to_s
51
53
  return result
52
54
  end
53
55
  end
@@ -35,12 +35,11 @@ module I18n
35
35
  def store_translations(locale, data, options = EMPTY_HASH)
36
36
  if I18n.enforce_available_locales &&
37
37
  I18n.available_locales_initialized? &&
38
- !I18n.available_locales.include?(locale.to_sym) &&
39
- !I18n.available_locales.include?(locale.to_s)
38
+ !I18n.locale_available?(locale)
40
39
  return data
41
40
  end
42
41
  locale = locale.to_sym
43
- translations[locale] ||= {}
42
+ translations[locale] ||= Concurrent::Hash.new
44
43
  data = data.deep_symbolize_keys
45
44
  translations[locale].deep_merge!(data)
46
45
  end
@@ -71,7 +70,7 @@ module I18n
71
70
  # call `init_translations`
72
71
  init_translations if do_init && !initialized?
73
72
 
74
- @translations ||= {}
73
+ @translations ||= Concurrent::Hash.new { |h, k| h[k] = Concurrent::Hash.new }
75
74
  end
76
75
 
77
76
  protected
@@ -4,7 +4,7 @@ module I18n
4
4
  using I18n::HashRefinements
5
5
  def except(*keys)
6
6
  dup.except!(*keys)
7
- end
7
+ end unless method_defined?(:except)
8
8
 
9
9
  def except!(*keys)
10
10
  keys.each { |key| delete(key) }
@@ -8,7 +8,7 @@ module I18n
8
8
  /%<(\w+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/ # matches placeholders like "%<foo>.d"
9
9
  ].freeze
10
10
  INTERPOLATION_PATTERN = Regexp.union(DEFAULT_INTERPOLATION_PATTERNS)
11
- deprecate_constant :INTERPOLATION_PATTERN if method_defined? :INTERPOLATION_PATTERN
11
+ deprecate_constant :INTERPOLATION_PATTERN
12
12
 
13
13
  class << self
14
14
  # Return String or raises MissingInterpolationArgument exception.
@@ -26,7 +26,7 @@
26
26
  #
27
27
  # I18n.default_locale = :"en-US"
28
28
  # I18n.fallbacks = I18n::Locale::Fallbacks.new(:"de-AT" => :"de-DE")
29
- # I18n.fallbacks[:"de-AT"] # => [:"de-AT", :"de-DE", :de, :"en-US", :en]
29
+ # I18n.fallbacks[:"de-AT"] # => [:"de-AT", :de, :"de-DE"]
30
30
  #
31
31
  # # using a custom locale as default fallback locale
32
32
  #
@@ -46,7 +46,7 @@
46
46
  # fallbacks[:"ar-PS"] # => [:"ar-PS", :ar, :"he-IL", :he, :"en-US", :en]
47
47
  # fallbacks[:"ar-EG"] # => [:"ar-EG", :ar, :"en-US", :en]
48
48
  #
49
- # # people speaking Sami as spoken in Finnland also speak Swedish and Finnish as spoken in Finnland
49
+ # # people speaking Sami as spoken in Finland also speak Swedish and Finnish as spoken in Finland
50
50
  # fallbacks.map(:sms => [:"se-FI", :"fi-FI"])
51
51
  # fallbacks[:sms] # => [:sms, :"se-FI", :se, :"fi-FI", :fi, :"en-US", :en]
52
52
 
data/lib/i18n/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18n
4
- VERSION = "1.8.3"
4
+ VERSION = "1.8.11"
5
5
  end
data/lib/i18n.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'concurrent/map'
4
+ require 'concurrent/hash'
4
5
 
5
6
  require 'i18n/version'
6
7
  require 'i18n/exceptions'
@@ -33,7 +34,7 @@ module I18n
33
34
  EMPTY_HASH = {}.freeze
34
35
 
35
36
  def self.new_double_nested_cache # :nodoc:
36
- Concurrent::Map.new { |h,k| h[k] = Concurrent::Map.new }
37
+ Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
37
38
  end
38
39
 
39
40
  module Base
@@ -192,7 +193,7 @@ module I18n
192
193
  # I18n.t(:salutation, { :gender => 'w', :name => 'Smith' })
193
194
  # I18n.t(:salutation, any_hash)
194
195
  #
195
- def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
196
+ def translate(key = nil, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
196
197
  locale ||= config.locale
197
198
  raise Disabled.new('t') if locale == false
198
199
  enforce_available_locales!(locale)
@@ -217,8 +218,8 @@ module I18n
217
218
 
218
219
  # Wrapper for <tt>translate</tt> that adds <tt>:raise => true</tt>. With
219
220
  # this option, if no translation is found, it will raise <tt>I18n::MissingTranslationData</tt>
220
- def translate!(key, options = EMPTY_HASH)
221
- translate(key, **options.merge(:raise => true))
221
+ def translate!(key, **options)
222
+ translate(key, **options, raise: true)
222
223
  end
223
224
  alias :t! :translate!
224
225
 
@@ -281,7 +282,7 @@ module I18n
281
282
  # I18n.transliterate("Jürgen") # => "Juergen"
282
283
  # I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
283
284
  # I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
284
- def transliterate(key, *, throw: false, raise: false, locale: nil, replacement: nil, **options)
285
+ def transliterate(key, throw: false, raise: false, locale: nil, replacement: nil, **options)
285
286
  locale ||= config.locale
286
287
  raise Disabled.new('transliterate') if locale == false
287
288
  enforce_available_locales!(locale)
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: 1.8.3
4
+ version: 1.8.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -10,18 +10,18 @@ authors:
10
10
  - Stephan Soller
11
11
  - Saimon Moore
12
12
  - Ryan Bigg
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2020-06-05 00:00:00.000000000 Z
16
+ date: 2021-11-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
- name: concurrent-ruby
20
19
  requirement: !ruby/object:Gem::Requirement
21
20
  requirements:
22
21
  - - "~>"
23
22
  - !ruby/object:Gem::Version
24
23
  version: '1.0'
24
+ name: concurrent-ruby
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -86,27 +86,11 @@ homepage: https://github.com/ruby-i18n/i18n
86
86
  licenses:
87
87
  - MIT
88
88
  metadata:
89
- bug_tracker_uri: https://github.com/svenfuchs/i18n/issues
90
- changelog_uri: https://github.com/svenfuchs/i18n/releases
89
+ bug_tracker_uri: https://github.com/ruby-i18n/i18n/issues
90
+ changelog_uri: https://github.com/ruby-i18n/i18n/releases
91
91
  documentation_uri: https://guides.rubyonrails.org/i18n.html
92
- source_code_uri: https://github.com/svenfuchs/i18n
93
- post_install_message: |2+
94
-
95
- HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
96
- But that may break your application.
97
-
98
- If you are upgrading your Rails application from an older version of Rails:
99
-
100
- Please check your Rails app for 'config.i18n.fallbacks = true'.
101
- If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
102
- 'config.i18n.fallbacks = [I18n.default_locale]'.
103
- If not, fallbacks will be broken in your app by I18n 1.1.x.
104
-
105
- If you are starting a NEW Rails application, you can ignore this notice.
106
-
107
- For more info see:
108
- https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
109
-
92
+ source_code_uri: https://github.com/ruby-i18n/i18n
93
+ post_install_message:
110
94
  rdoc_options: []
111
95
  require_paths:
112
96
  - lib
@@ -121,8 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
105
  - !ruby/object:Gem::Version
122
106
  version: 1.3.5
123
107
  requirements: []
124
- rubygems_version: 3.1.2
125
- signing_key:
108
+ rubygems_version: 3.0.6
109
+ signing_key:
126
110
  specification_version: 4
127
111
  summary: New wave Internationalization support for Ruby
128
112
  test_files: []