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
This commit is contained in:
commit
61bec3cf9c
@ -23,7 +23,7 @@ GEM
|
|||||||
hpricot (0.8.6)
|
hpricot (0.8.6)
|
||||||
http-cookie (1.0.3)
|
http-cookie (1.0.3)
|
||||||
domain_name (~> 0.5)
|
domain_name (~> 0.5)
|
||||||
i18n (1.5.3)
|
i18n (1.6.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
jaro_winkler (1.5.2)
|
jaro_winkler (1.5.2)
|
||||||
json (2.2.0)
|
json (2.2.0)
|
||||||
|
|||||||
@ -20,8 +20,11 @@ module Homebrew
|
|||||||
|
|
||||||
Homebrew.install_bundler!
|
Homebrew.install_bundler!
|
||||||
|
|
||||||
ohai "cd #{HOMEBREW_LIBRARY_PATH}/vendor"
|
ohai "cd #{HOMEBREW_LIBRARY_PATH}"
|
||||||
HOMEBREW_LIBRARY_PATH.cd do
|
HOMEBREW_LIBRARY_PATH.cd do
|
||||||
|
ohai "bundle pristine"
|
||||||
|
safe_system "bundle", "pristine"
|
||||||
|
|
||||||
ohai "bundle install --standalone"
|
ohai "bundle install --standalone"
|
||||||
safe_system "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"]
|
ruby_version = RbConfig::CONFIG["ruby_version"]
|
||||||
path = File.expand_path('..', __FILE__)
|
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/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/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/thread_safe-0.3.6/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/tzinfo-1.2.5/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}/../#{ruby_engine}/#{ruby_version}/gems/backports-3.12.0/lib"
|
||||||
$:.unshift "#{path}/"
|
$:.unshift "#{path}/"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/connection_pool-2.2.2/lib"
|
$:.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}/extensions/universal-darwin-18/2.3.0/json-2.2.0"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.1.0/lib"
|
$:.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/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-html-0.10.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.16.1/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/webrobots-0.1.2/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/mechanize-2.7.6/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/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/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/parser-2.6.0.0/lib"
|
||||||
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/plist-3.5.0/lib"
|
||||||
|
|||||||
@ -69,6 +69,13 @@ module I18n
|
|||||||
config.backend.reload!
|
config.backend.reload!
|
||||||
end
|
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,
|
# Translates, pluralizes and interpolates a given key using a given locale,
|
||||||
# scope, and default, as well as interpolation values.
|
# 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
|
# from the argument values passed to #translate. Therefor your lambdas should
|
||||||
# always return the same translations/values per unique combination of argument
|
# always return the same translations/values per unique combination of argument
|
||||||
# values.
|
# values.
|
||||||
def translate(*args)
|
def translate(key = nil, *, throw: false, raise: false, locale: nil, **options) # TODO deprecate :raise
|
||||||
options = args.last.is_a?(Hash) ? args.pop.dup : {}
|
locale ||= config.locale
|
||||||
key = args.shift
|
raise Disabled.new('t') if locale == false
|
||||||
backend = config.backend
|
|
||||||
locale = options.delete(:locale) || config.locale
|
|
||||||
handling = options.delete(:throw) && :throw || options.delete(:raise) && :raise # TODO deprecate :raise
|
|
||||||
|
|
||||||
enforce_available_locales!(locale)
|
enforce_available_locales!(locale)
|
||||||
|
|
||||||
|
backend = config.backend
|
||||||
|
|
||||||
result = catch(:exception) do
|
result = catch(:exception) do
|
||||||
if key.is_a?(Array)
|
if key.is_a?(Array)
|
||||||
key.map { |k| backend.translate(locale, k, options) }
|
key.map { |k| backend.translate(locale, k, options) }
|
||||||
@ -185,7 +190,12 @@ module I18n
|
|||||||
backend.translate(locale, key, options)
|
backend.translate(locale, key, options)
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
alias :t :translate
|
alias :t :translate
|
||||||
|
|
||||||
@ -197,7 +207,9 @@ module I18n
|
|||||||
alias :t! :translate!
|
alias :t! :translate!
|
||||||
|
|
||||||
# Returns true if a translation exists for a given key, otherwise returns false.
|
# 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?
|
raise I18n::ArgumentError if key.is_a?(String) && key.empty?
|
||||||
config.backend.exists?(locale, key)
|
config.backend.exists?(locale, key)
|
||||||
end
|
end
|
||||||
@ -253,37 +265,40 @@ module I18n
|
|||||||
# I18n.transliterate("Jürgen") # => "Juergen"
|
# I18n.transliterate("Jürgen") # => "Juergen"
|
||||||
# I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
|
# I18n.transliterate("Jürgen", :locale => :en) # => "Jurgen"
|
||||||
# I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
|
# I18n.transliterate("Jürgen", :locale => :de) # => "Juergen"
|
||||||
def transliterate(*args)
|
def transliterate(key, *, throw: false, raise: false, locale: nil, replacement: nil, **options)
|
||||||
options = args.pop.dup if args.last.is_a?(Hash)
|
locale ||= config.locale
|
||||||
key = args.shift
|
raise Disabled.new('transliterate') if locale == false
|
||||||
locale = options && options.delete(:locale) || config.locale
|
|
||||||
handling = options && (options.delete(:throw) && :throw || options.delete(:raise) && :raise)
|
|
||||||
replacement = options && options.delete(:replacement)
|
|
||||||
enforce_available_locales!(locale)
|
enforce_available_locales!(locale)
|
||||||
|
|
||||||
config.backend.transliterate(locale, key, replacement)
|
config.backend.transliterate(locale, key, replacement)
|
||||||
rescue I18n::ArgumentError => exception
|
rescue I18n::ArgumentError => exception
|
||||||
handle_exception(handling, exception, locale, key, options || {})
|
handle_exception((throw && :throw || raise && :raise), exception, locale, key, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Localizes certain objects, such as dates and numbers to local formatting.
|
# Localizes certain objects, such as dates and numbers to local formatting.
|
||||||
def localize(object, options = nil)
|
def localize(object, locale: nil, format: nil, **options)
|
||||||
options = options ? options.dup : {}
|
locale ||= config.locale
|
||||||
locale = options.delete(:locale) || config.locale
|
raise Disabled.new('l') if locale == false
|
||||||
format = options.delete(:format) || :default
|
|
||||||
enforce_available_locales!(locale)
|
enforce_available_locales!(locale)
|
||||||
|
|
||||||
|
format ||= :default
|
||||||
config.backend.localize(locale, object, format, options)
|
config.backend.localize(locale, object, format, options)
|
||||||
end
|
end
|
||||||
alias :l :localize
|
alias :l :localize
|
||||||
|
|
||||||
# Executes block with given I18n.locale set.
|
# Executes block with given I18n.locale set.
|
||||||
def with_locale(tmp_locale = nil)
|
def with_locale(tmp_locale = nil)
|
||||||
if tmp_locale
|
if tmp_locale == nil
|
||||||
|
yield
|
||||||
|
else
|
||||||
current_locale = self.locale
|
current_locale = self.locale
|
||||||
self.locale = tmp_locale
|
self.locale = tmp_locale
|
||||||
end
|
begin
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
self.locale = current_locale if tmp_locale
|
self.locale = current_locale
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Merges the given locale, key and scope into a single array of keys.
|
# 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.
|
# Raises an InvalidLocale exception when the passed locale is not available.
|
||||||
def enforce_available_locales!(locale)
|
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)
|
raise I18n::InvalidLocale.new(locale) if !locale_available?(locale)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -95,10 +95,19 @@ module I18n
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reload!
|
def reload!
|
||||||
|
eager_load! if eager_loaded?
|
||||||
|
end
|
||||||
|
|
||||||
|
def eager_load!
|
||||||
|
@eager_loaded = true
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def eager_loaded?
|
||||||
|
@eager_loaded ||= false
|
||||||
|
end
|
||||||
|
|
||||||
# The method which actually looks up for the translation in the store.
|
# The method which actually looks up for the translation in the store.
|
||||||
def lookup(locale, key, scope = [], options = EMPTY_HASH)
|
def lookup(locale, key, scope = [], options = EMPTY_HASH)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -248,12 +257,16 @@ module I18n
|
|||||||
end
|
end
|
||||||
|
|
||||||
def translate_localization_format(locale, object, format, options)
|
def translate_localization_format(locale, object, format, options)
|
||||||
format.to_s.gsub(/%[aAbBpP]/) do |match|
|
format.to_s.gsub(/%(|\^)[aAbBpP]/) do |match|
|
||||||
case 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]
|
||||||
|
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]
|
||||||
|
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]
|
||||||
|
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]
|
||||||
|
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).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
|
when '%P' then I18n.t!(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).downcase if object.respond_to? :hour
|
||||||
end
|
end
|
||||||
@ -106,7 +106,7 @@ module I18n
|
|||||||
private
|
private
|
||||||
|
|
||||||
def digest_item(key)
|
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
|
end
|
||||||
end
|
end
|
||||||
@ -41,6 +41,10 @@ module I18n
|
|||||||
backends.each { |backend| backend.reload! }
|
backends.each { |backend| backend.reload! }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def eager_load!
|
||||||
|
backends.each { |backend| backend.eager_load! }
|
||||||
|
end
|
||||||
|
|
||||||
def store_translations(locale, data, options = EMPTY_HASH)
|
def store_translations(locale, data, options = EMPTY_HASH)
|
||||||
backends.first.store_translations(locale, data, options)
|
backends.first.store_translations(locale, data, options)
|
||||||
end
|
end
|
||||||
@ -26,6 +26,12 @@ module I18n
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def eager_load!
|
||||||
|
memoized_lookup
|
||||||
|
available_locales
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def lookup(locale, key, scope = nil, options = EMPTY_HASH)
|
def lookup(locale, key, scope = nil, options = EMPTY_HASH)
|
||||||
@ -63,6 +63,11 @@ module I18n
|
|||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def eager_load!
|
||||||
|
init_translations unless initialized?
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
def translations(do_init: false)
|
def translations(do_init: false)
|
||||||
# To avoid returning empty translations,
|
# To avoid returning empty translations,
|
||||||
# call `init_translations`
|
# call `init_translations`
|
||||||
@ -7,7 +7,7 @@ module I18n
|
|||||||
# The only configuration value that is not global and scoped to thread is :locale.
|
# The only configuration value that is not global and scoped to thread is :locale.
|
||||||
# It defaults to the default_locale.
|
# It defaults to the default_locale.
|
||||||
def locale
|
def locale
|
||||||
defined?(@locale) && @locale ? @locale : default_locale
|
defined?(@locale) && @locale != nil ? @locale : default_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
|
# Sets the current locale pseudo-globally, i.e. in the Thread.current hash.
|
||||||
@ -15,6 +15,20 @@ module I18n
|
|||||||
|
|
||||||
class ArgumentError < ::ArgumentError; end
|
class ArgumentError < ::ArgumentError; end
|
||||||
|
|
||||||
|
class Disabled < ArgumentError
|
||||||
|
def initialize(method)
|
||||||
|
super(<<~MESSAGE)
|
||||||
|
I18n.#{method} is currently disabled, likely because your application is still in its loading phase.
|
||||||
|
|
||||||
|
This method is meant to display text in the user locale, so calling it before the user locale has
|
||||||
|
been set is likely to display text from the wrong locale to some users.
|
||||||
|
|
||||||
|
If you have a legitimate reason to access i18n data outside of the user flow, you can do so by passing
|
||||||
|
the desired locale explictly with the `locale` argument, e.g. `I18n.#{method}(..., locale: :en)`
|
||||||
|
MESSAGE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class InvalidLocale < ArgumentError
|
class InvalidLocale < ArgumentError
|
||||||
attr_reader :locale
|
attr_reader :locale
|
||||||
def initialize(locale)
|
def initialize(locale)
|
||||||
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module I18n
|
module I18n
|
||||||
VERSION = "1.5.3"
|
VERSION = "1.6.0"
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user