Skip to content
Snippets Groups Projects
Unverified Commit 61bec3cf authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #5832 from Homebrew/dependabot/bundler/Library/Homebrew/i18n-1.6.0

Bump i18n from 1.5.3 to 1.6.0 in /Library/Homebrew
parents d9b43928 fa203f76
No related branches found
No related tags found
No related merge requests found
Showing
with 80 additions and 34 deletions
......@@ -23,7 +23,7 @@ GEM
hpricot (0.8.6)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.5.3)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.2)
json (2.2.0)
......
......@@ -20,8 +20,11 @@ module Homebrew
Homebrew.install_bundler!
ohai "cd #{HOMEBREW_LIBRARY_PATH}/vendor"
ohai "cd #{HOMEBREW_LIBRARY_PATH}"
HOMEBREW_LIBRARY_PATH.cd do
ohai "bundle pristine"
safe_system "bundle", "pristine"
ohai "bundle install --standalone"
safe_system "bundle", "install", "--standalone"
......
......@@ -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.4/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.5.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/i18n-1.6.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/minitest-5.11.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/thread_safe-0.3.6/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-1.2.5/lib"
......@@ -13,8 +13,8 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ast-2.4.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.12.0/lib"
$:.unshift "#{path}/"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-18/2.3.0/json-2.1.0"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwin-18/2.3.0/json-2.2.0"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.2.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.10.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.16.1/lib"
......@@ -43,7 +43,7 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/ntlm-http-0.1.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/webrobots-0.1.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mustache-1.1.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.13.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel-1.14.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parallel_tests-2.28.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/parser-2.6.0.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
......
......@@ -69,6 +69,13 @@ module I18n
config.backend.reload!
end
# Tells the backend to load translations now. Used in situations like the
# Rails production environment. Backends can implement whatever strategy
# is useful.
def eager_load!
config.backend.eager_load!
end
# Translates, pluralizes and interpolates a given key using a given locale,
# scope, and default, as well as interpolation values.
#
......@@ -169,15 +176,13 @@ module I18n
# from the argument values passed to #translate. Therefor your lambdas should
# always return the same translations/values per unique combination of argument
# values.
def translate(*args)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
key = args.shift
backend = config.backend
locale = options.delete(:locale) || config.locale
handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise
def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
locale ||= config.locale
raise Disabled.new('t') if locale == false
enforce_available_locales!(locale)
backend = config.backend
result = catch(:exception) do
if key.is_a?(Array)
key.map { |k| backend.translate(locale, k, options) }
......@@ -185,7 +190,12 @@ module I18n
backend.translate(locale, key, options)
end
end
result.is_a?(MissingTranslation) ? handle_exception(handling, result, locale, key, options) : result
if result.is_a?(MissingTranslation)
handle_exception((throw && :throw || raise && :raise), result, locale, key, options)
else
result
end
end
alias :t :translate
......@@ -197,7 +207,9 @@ module I18n
alias :t! :translate!
# Returns true if a translation exists for a given key, otherwise returns false.
def exists?(key, locale = config.locale)
def exists?(key, _locale = nil, locale: _locale)
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)
end
......@@ -253,37 +265,40 @@ module I18n
# I18n.transliterate("Jürgen") # => "Juergen"
# I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
# I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
def transliterate(*args)
options = args.pop.dup if args.last.is_a?(Hash)
key = args.shift
locale = options && options.delete(:locale) || config.locale
handling = options && (options.delete(:throw) && :throw || options.delete(:raise) && :raise)
replacement = options && options.delete(:replacement)
def transliterate(key, *, throw: false, raise: false, locale: nil, replacement: nil, **options)
locale ||= config.locale
raise Disabled.new('transliterate') if locale == false
enforce_available_locales!(locale)
config.backend.transliterate(locale, key, replacement)
rescue I18n::ArgumentError => exception
handle_exception(handling, exception, locale, key, options || {})
handle_exception((throw && :throw || raise && :raise), exception, locale, key, options)
end
# Localizes certain objects, such as dates and numbers to local formatting.
def localize(object, options = nil)
options = options ? options.dup : {}
locale = options.delete(:locale) || config.locale
format = options.delete(:format) || :default
def localize(object, locale: nil, format: nil, **options)
locale ||= config.locale
raise Disabled.new('l') if locale == false
enforce_available_locales!(locale)
format ||= :default
config.backend.localize(locale, object, format, options)
end
alias :l :localize
# Executes block with given I18n.locale set.
def with_locale(tmp_locale = nil)
if tmp_locale
if tmp_locale == nil
yield
else
current_locale = self.locale
self.locale = tmp_locale
self.locale = tmp_locale
begin
yield
ensure
self.locale = current_locale
end
end
yield
ensure
self.locale = current_locale if tmp_locale
end
# Merges the given locale, key and scope into a single array of keys.
......@@ -307,7 +322,7 @@ module I18n
# Raises an InvalidLocale exception when the passed locale is not available.
def enforce_available_locales!(locale)
if config.enforce_available_locales
if locale != false && config.enforce_available_locales
raise I18n::InvalidLocale.new(locale) if !locale_available?(locale)
end
end
......
......@@ -95,10 +95,19 @@ module I18n
end
def reload!
eager_load! if eager_loaded?
end
def eager_load!
@eager_loaded = true
end
protected
def eager_loaded?
@eager_loaded ||= false
end
# The method which actually looks up for the translation in the store.
def lookup(locale, key, scope = [], options = EMPTY_HASH)
raise NotImplementedError
......@@ -248,12 +257,16 @@ module I18n
end
def translate_localization_format(locale, object, format, options)
format.to_s.gsub(/%[aAbBpP]/) do |match|
format.to_s.gsub(/%(|\^)[aAbBpP]/) do |match|
case match
when '%a' then I18n.t!(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday]
when '%^a' then I18n.t!(:"date.abbr_day_names", :locale => locale, :format => format)[object.wday].upcase
when '%A' then I18n.t!(:"date.day_names", :locale => locale, :format => format)[object.wday]
when '%^A' then I18n.t!(:"date.day_names", :locale => locale, :format => format)[object.wday].upcase
when '%b' then I18n.t!(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon]
when '%^b' then I18n.t!(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon].upcase
when '%B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon]
when '%^B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon].upcase
when '%p' then I18n.t!(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).upcase if object.respond_to? :hour
when '%P' then I18n.t!(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).downcase if object.respond_to? :hour
end
......
......@@ -106,7 +106,7 @@ module I18n
private
def digest_item(key)
I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.hash
I18n.cache_key_digest ? I18n.cache_key_digest.hexdigest(key.to_s) : key.to_s.hash
end
end
end
......
......@@ -41,6 +41,10 @@ module I18n
backends.each { |backend| backend.reload! }
end
def eager_load!
backends.each { |backend| backend.eager_load! }
end
def store_translations(locale, data, options = EMPTY_HASH)
backends.first.store_translations(locale, data, options)
end
......
......@@ -26,6 +26,12 @@ module I18n
super
end
def eager_load!
memoized_lookup
available_locales
super
end
protected
def lookup(locale, key, scope = nil, options = EMPTY_HASH)
......
......@@ -63,6 +63,11 @@ module I18n
super
end
def eager_load!
init_translations unless initialized?
super
end
def translations(do_init: false)
# To avoid returning empty translations,
# call `init_translations`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment