Merge pull request #7699 from Homebrew/dependabot/bundler/Library/Homebrew/i18n-1.8.3

build(deps): bump i18n from 1.8.2 to 1.8.3 in /Library/Homebrew
This commit is contained in:
Mike McQuaid 2020-06-05 11:08:31 +01:00 committed by GitHub
commit 13caf6e6bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 81 additions and 51 deletions

View File

@ -24,7 +24,7 @@ GEM
hpricot (0.8.6)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.2)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
json (2.3.0)
mechanize (2.7.6)

View File

@ -4,7 +4,7 @@ ruby_engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
ruby_version = RbConfig::CONFIG["ruby_version"]
path = File.expand_path('..', __FILE__)
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.8.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.14.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-1.2.7/lib"

View File

@ -1,22 +0,0 @@
module I18n
module Locale
module Tag
module Parents
def parent
@parent ||= begin
segs = to_a.compact
segs.length > 1 ? self.class.tag(*segs[0..(segs.length-2)].join('-')) : nil
end
end
def self_and_parents
@self_and_parents ||= [self] + parents
end
def parents
@parents ||= ([parent] + (parent ? parent.parents : [])).compact
end
end
end
end
end

View File

@ -223,11 +223,11 @@ module I18n
alias :t! :translate!
# Returns true if a translation exists for a given key, otherwise returns false.
def exists?(key, _locale = nil, locale: _locale)
def exists?(key, _locale = nil, locale: _locale, **options)
locale ||= config.locale
raise Disabled.new('exists?') if locale == false
raise I18n::ArgumentError if key.is_a?(String) && key.empty?
config.backend.exists?(locale, key)
config.backend.exists?(locale, key, options)
end
# Transliterates UTF-8 characters to ASCII. By default this method will
@ -389,7 +389,7 @@ module I18n
@@normalized_key_cache[separator][key] ||=
case key
when Array
key.map { |k| normalize_key(k, separator) }.flatten
key.flat_map { |k| normalize_key(k, separator) }
else
keys = key.to_s.split(separator)
keys.delete('')

View File

@ -64,7 +64,7 @@ module I18n
entry
end
def exists?(locale, key)
def exists?(locale, key, options = EMPTY_HASH)
lookup(locale, key) != nil
end
@ -146,7 +146,7 @@ module I18n
I18n.translate(subject, **options.merge(:locale => locale, :throw => true))
when Proc
date_or_time = options.delete(:object) || object
resolve(locale, object, subject.call(date_or_time, options))
resolve(locale, object, subject.call(date_or_time, **options))
else
subject
end
@ -163,6 +163,7 @@ module I18n
# not standard with regards to the CLDR pluralization rules.
# Other backends can implement more flexible or complex pluralization rules.
def pluralize(locale, entry, count)
entry = entry.reject { |k, _v| k == :attributes } if entry.is_a?(Hash)
return entry unless entry.is_a?(Hash) && count && entry.values.none? { |v| v.is_a?(Hash) }
key = pluralization_key(entry, count)

View File

@ -73,9 +73,9 @@ module I18n
throw(:exception, I18n::MissingTranslation.new(locale, key, options))
end
def exists?(locale, key)
def exists?(locale, key, options = EMPTY_HASH)
backends.any? do |backend|
backend.exists?(locale, key)
backend.exists?(locale, key, options)
end
end
@ -101,8 +101,7 @@ module I18n
init_translations unless initialized?
translations
end
memo.deep_merge!(partial_translations)
memo.deep_merge!(partial_translations) { |_, a, b| b || a }
end
end

View File

@ -46,7 +46,10 @@ module I18n
begin
catch(:exception) do
result = super(fallback, key, fallback_options)
return result unless result.nil?
unless result.nil?
on_fallback(locale, fallback, key, options) if locale != fallback
return result
end
end
rescue I18n::InvalidLocale
# we do nothing when the locale is invalid, as this is a fallback anyways.
@ -68,7 +71,8 @@ module I18n
return first_non_symbol_default
end
def exists?(locale, key)
def exists?(locale, key, options = EMPTY_HASH)
return super unless options.fetch(:fallback, true)
I18n.fallbacks[locale].each do |fallback|
begin
return true if super(fallback, key)
@ -79,6 +83,13 @@ module I18n
false
end
private
# Overwrite on_fallback to add specified logic when the fallback succeeds.
def on_fallback(_original_locale, _fallback_locale, _key, _optoins)
nil
end
end
end
end

View File

@ -18,14 +18,17 @@ module I18n
# and creates way less objects than the one at I18n.normalize_keys.
# It also handles escaping the translation keys.
def self.normalize_flat_keys(locale, key, scope, separator)
keys = [scope, key].flatten.compact
keys = [scope, key]
keys.flatten!
keys.compact!
separator ||= I18n.default_separator
if separator != FLATTEN_SEPARATOR
keys.map! do |k|
k.to_s.tr("#{FLATTEN_SEPARATOR}#{separator}",
"#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}")
end
from_str = "#{FLATTEN_SEPARATOR}#{separator}"
to_str = "#{SEPARATOR_ESCAPE_CHAR}#{FLATTEN_SEPARATOR}"
keys.map! { |k| k.to_s.tr from_str, to_str }
end
keys.join(".")

View File

@ -18,12 +18,24 @@ module I18n
end
end
# deep_merge_hash! by Stefan Rusterholz, see http://www.ruby-forum.com/topic/142809
def deep_merge!(data)
merger = lambda do |_key, v1, v2|
Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
# deep_merge from activesupport 5
# Copyright (c) 2005-2019 David Heinemeier Hansson
def deep_merge(other_hash, &block)
dup.deep_merge!(other_hash, &block)
end
# deep_merge! from activesupport 5
# Copyright (c) 2005-2019 David Heinemeier Hansson
def deep_merge!(other_hash, &block)
merge!(other_hash) do |key, this_val, other_val|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
this_val.deep_merge(other_val, &block)
elsif block_given?
block.call(key, this_val, other_val)
else
other_val
end
end
merge!(data, &merger)
end
def symbolize_key(key)

View File

@ -60,7 +60,7 @@ module I18n
end
def defaults=(defaults)
@defaults = defaults.map { |default| compute(default, false) }.flatten
@defaults = defaults.flat_map { |default| compute(default, false) }
end
attr_reader :defaults
@ -84,13 +84,15 @@ module I18n
protected
def compute(tags, include_defaults = true, exclude = [])
result = Array(tags).collect do |tag|
result = Array(tags).flat_map do |tag|
tags = I18n::Locale::Tag.tag(tag).self_and_parents.map! { |t| t.to_sym } - exclude
tags.each { |_tag| tags += compute(@map[_tag], false, exclude + tags) if @map[_tag] }
tags
end.flatten
end
result.push(*defaults) if include_defaults
result.uniq.compact
result.uniq!
result.compact!
result
end
end
end

View File

@ -0,0 +1,24 @@
module I18n
module Locale
module Tag
module Parents
def parent
@parent ||=
begin
segs = to_a
segs.compact!
segs.length > 1 ? self.class.tag(*segs[0..(segs.length - 2)].join('-')) : nil
end
end
def self_and_parents
@self_and_parents ||= [self].concat parents
end
def parents
@parents ||= parent ? [parent].concat(parent.parents) : []
end
end
end
end
end

View File

@ -19,7 +19,7 @@ module I18n
end
def subtags
@subtags = tag.to_s.split('-').map { |subtag| subtag.to_s }
@subtags = tag.to_s.split('-').map!(&:to_s)
end
def to_sym

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module I18n
VERSION = "1.8.2"
VERSION = "1.8.3"
end