Merge pull request #15316 from Homebrew/dependabot/bundler/Library/Homebrew/i18n-1.13.0
build(deps): bump i18n from 1.12.0 to 1.13.0 in /Library/Homebrew
This commit is contained in:
commit
7386d4e407
@ -28,7 +28,7 @@ GEM
|
||||
hana (1.3.7)
|
||||
highline (2.0.3)
|
||||
hpricot (0.8.6)
|
||||
i18n (1.12.0)
|
||||
i18n (1.13.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.6.3)
|
||||
json_schemer (0.2.24)
|
||||
|
||||
@ -333,6 +333,10 @@ module I18n::Backend::Pluralization
|
||||
|
||||
def pluralizer(locale); end
|
||||
def pluralizers; end
|
||||
|
||||
private
|
||||
|
||||
def symbolic_count(count); end
|
||||
end
|
||||
|
||||
class I18n::Backend::Simple
|
||||
@ -358,6 +362,8 @@ module I18n::Backend::Simple::Implementation
|
||||
def lookup(locale, key, scope = T.unsafe(nil), options = T.unsafe(nil)); end
|
||||
end
|
||||
|
||||
I18n::Backend::Simple::Implementation::MUTEX = T.let(T.unsafe(nil), Thread::Mutex)
|
||||
|
||||
module I18n::Backend::Transliterator
|
||||
def transliterate(locale, string, replacement = T.unsafe(nil)); end
|
||||
|
||||
@ -495,6 +501,7 @@ end
|
||||
|
||||
I18n::Gettext::PLURAL_SEPARATOR = T.let(T.unsafe(nil), String)
|
||||
I18n::INTERPOLATION_PATTERN = T.let(T.unsafe(nil), Regexp)
|
||||
I18n::INTERPOLATION_PATTERNS_CACHE = T.let(T.unsafe(nil), Hash)
|
||||
|
||||
class I18n::InvalidFilenames < ::I18n::ArgumentError
|
||||
def initialize(file_errors); end
|
||||
@ -644,49 +651,12 @@ end
|
||||
|
||||
module I18n::Tests; end
|
||||
|
||||
module I18n::Tests::Basics
|
||||
def teardown; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Defaults
|
||||
def setup; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Interpolation; end
|
||||
module I18n::Tests::Link; end
|
||||
|
||||
module I18n::Tests::Localization
|
||||
include ::I18n::Tests::Localization::Date
|
||||
include ::I18n::Tests::Localization::DateTime
|
||||
include ::I18n::Tests::Localization::Procs
|
||||
include ::I18n::Tests::Localization::Time
|
||||
|
||||
class << self
|
||||
def included(base); end
|
||||
end
|
||||
end
|
||||
|
||||
module I18n::Tests::Localization::Date
|
||||
def setup; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Localization::DateTime
|
||||
def setup; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Localization::Procs; end
|
||||
|
||||
module I18n::Tests::Localization::Time
|
||||
def setup; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Lookup
|
||||
def setup; end
|
||||
end
|
||||
|
||||
module I18n::Tests::Pluralization; end
|
||||
module I18n::Tests::Procs; end
|
||||
|
||||
class I18n::UnknownFileType < ::I18n::ArgumentError
|
||||
def initialize(type, filename); end
|
||||
|
||||
20
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
20
Library/Homebrew/vendor/bundle/bundler/setup.rb
vendored
@ -24,7 +24,7 @@ kernel = (class << ::Kernel; self; end)
|
||||
end
|
||||
end
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/i18n-1.12.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/i18n-1.13.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/minitest-5.18.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/tzinfo-2.0.6/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/zeitwerk-2.6.7/lib")
|
||||
@ -33,11 +33,11 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/addressable-2.8.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ast-2.4.2/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/bindata-2.4.15/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/msgpack-1.7.0")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/msgpack-1.7.0")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/msgpack-1.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/bootsnap-1.16.0")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/bootsnap-1.16.0")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/bootsnap-1.16.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/byebug-11.1.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/byebug-11.1.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/byebug-11.1.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/coderay-1.1.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/highline-2.0.3/lib")
|
||||
@ -49,9 +49,9 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ecma-re-validator-0.4.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/elftools-1.2.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/hana-1.3.7/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/hpricot-0.8.6")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/hpricot-0.8.6")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/hpricot-0.8.6/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/json-2.6.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/json-2.6.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json-2.6.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/uri_template-0.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/json_schemer-0.2.24/lib")
|
||||
@ -69,7 +69,7 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rack-3.0.7/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/unparser-0.6.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rbi-0.0.14/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/rdiscount-2.2.7")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/rdiscount-2.2.7")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rdiscount-2.2.7/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rexml-3.2.5/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ronn-0.7.3/lib")
|
||||
@ -93,18 +93,18 @@ $:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-rspec-2.20.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/rubocop-sorbet-0.7.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-macho-3.0.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/ruby-prof-1.4.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/ruby-prof-1.4.3")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/ruby-prof-1.4.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-html-0.12.3/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov_json_formatter-0.1.4/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-0.22.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/simplecov-cobertura-2.1.0/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.5.10461-universal-darwin-21/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-0.5.10461-universal-darwin-22/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-0.5.10461/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/sorbet-static-and-runtime-0.5.10461/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/thor-1.2.1/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/spoom-1.1.11/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-21/#{Gem.extension_api_version}/stackprof-0.2.25")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/extensions/universal-darwin-22/#{Gem.extension_api_version}/stackprof-0.2.25")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/stackprof-0.2.25/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/yard-0.9.34/lib")
|
||||
$:.unshift File.expand_path("#{__dir__}/../#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/yard-sorbet-0.6.1/lib")
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# I18n Pluralization are useful when you want your application to
|
||||
# customize pluralization rules.
|
||||
#
|
||||
# To enable locale specific pluralizations you can simply include the
|
||||
# Pluralization module to the Simple backend - or whatever other backend you
|
||||
# are using.
|
||||
#
|
||||
# I18n::Backend::Simple.include(I18n::Backend::Pluralization)
|
||||
#
|
||||
# You also need to make sure to provide pluralization algorithms to the
|
||||
# backend, i.e. include them to your I18n.load_path accordingly.
|
||||
module I18n
|
||||
module Backend
|
||||
module Pluralization
|
||||
# Overwrites the Base backend translate method so that it will check the
|
||||
# translation meta data space (:i18n) for a locale specific pluralization
|
||||
# rule and use it to pluralize the given entry. I.e. the library expects
|
||||
# pluralization rules to be stored at I18n.t(:'i18n.plural.rule')
|
||||
#
|
||||
# Pluralization rules are expected to respond to #call(count) and
|
||||
# return a pluralization key. Valid keys depend on the translation data
|
||||
# hash (entry) but it is generally recommended to follow CLDR's style,
|
||||
# i.e., return one of the keys :zero, :one, :few, :many, :other.
|
||||
#
|
||||
# The :zero key is always picked directly when count equals 0 AND the
|
||||
# translation data has the key :zero. This way translators are free to
|
||||
# either pick a special :zero translation even for languages where the
|
||||
# pluralizer does not return a :zero key.
|
||||
def pluralize(locale, entry, count)
|
||||
return entry unless entry.is_a?(Hash) && count
|
||||
|
||||
pluralizer = pluralizer(locale)
|
||||
if pluralizer.respond_to?(:call)
|
||||
key = count == 0 && entry.has_key?(:zero) ? :zero : pluralizer.call(count)
|
||||
raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
|
||||
entry[key]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def pluralizers
|
||||
@pluralizers ||= {}
|
||||
end
|
||||
|
||||
def pluralizer(locale)
|
||||
pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -331,12 +331,11 @@ module I18n
|
||||
# keys are Symbols.
|
||||
def normalize_keys(locale, key, scope, separator = nil)
|
||||
separator ||= I18n.default_separator
|
||||
locale = locale.to_sym if locale
|
||||
|
||||
[
|
||||
*normalize_key(locale, separator),
|
||||
*normalize_key(scope, separator),
|
||||
*normalize_key(key, separator)
|
||||
]
|
||||
result = [locale]
|
||||
result.concat(normalize_key(scope, separator)) if scope
|
||||
result.concat(normalize_key(key, separator))
|
||||
end
|
||||
|
||||
# Returns true when the passed locale, which can be either a String or a
|
||||
@ -54,7 +54,7 @@ module I18n
|
||||
end
|
||||
|
||||
deep_interpolation = options[:deep_interpolation]
|
||||
values = Utils.except(options, *RESERVED_KEYS)
|
||||
values = Utils.except(options, *RESERVED_KEYS) unless options.empty?
|
||||
if values
|
||||
entry = if deep_interpolation
|
||||
deep_interpolate(locale, entry, values)
|
||||
@ -66,7 +66,7 @@ module I18n
|
||||
end
|
||||
|
||||
def exists?(locale, key, options = EMPTY_HASH)
|
||||
lookup(locale, key) != nil
|
||||
lookup(locale, key, options[:scope]) != nil
|
||||
end
|
||||
|
||||
# Acts the same as +strftime+, but uses a localized version of the
|
||||
@ -123,7 +123,12 @@ module I18n
|
||||
# first translation that can be resolved. Otherwise it tries to resolve
|
||||
# the translation directly.
|
||||
def default(locale, object, subject, options = EMPTY_HASH)
|
||||
options = options.reject { |key, value| key == :default }
|
||||
if options.size == 1 && options.has_key?(:default)
|
||||
options = {}
|
||||
else
|
||||
options = Utils.except(options, :default)
|
||||
end
|
||||
|
||||
case subject
|
||||
when Array
|
||||
subject.each do |item|
|
||||
@ -166,7 +171,7 @@ module I18n
|
||||
# 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) }
|
||||
return entry unless entry.is_a?(Hash) && count
|
||||
|
||||
key = pluralization_key(entry, count)
|
||||
raise InvalidPluralizationData.new(entry, count, key) unless entry.has_key?(key)
|
||||
@ -282,8 +287,8 @@ module I18n
|
||||
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
|
||||
when '%p' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).upcase
|
||||
when '%P' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).downcase
|
||||
end
|
||||
end
|
||||
rescue MissingTranslationData => e
|
||||
96
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.13.0/lib/i18n/backend/pluralization.rb
vendored
Normal file
96
Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.13.0/lib/i18n/backend/pluralization.rb
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# I18n Pluralization are useful when you want your application to
|
||||
# customize pluralization rules.
|
||||
#
|
||||
# To enable locale specific pluralizations you can simply include the
|
||||
# Pluralization module to the Simple backend - or whatever other backend you
|
||||
# are using.
|
||||
#
|
||||
# I18n::Backend::Simple.include(I18n::Backend::Pluralization)
|
||||
#
|
||||
# You also need to make sure to provide pluralization algorithms to the
|
||||
# backend, i.e. include them to your I18n.load_path accordingly.
|
||||
module I18n
|
||||
module Backend
|
||||
module Pluralization
|
||||
# Overwrites the Base backend translate method so that it will check the
|
||||
# translation meta data space (:i18n) for a locale specific pluralization
|
||||
# rule and use it to pluralize the given entry. I.e., the library expects
|
||||
# pluralization rules to be stored at I18n.t(:'i18n.plural.rule')
|
||||
#
|
||||
# Pluralization rules are expected to respond to #call(count) and
|
||||
# return a pluralization key. Valid keys depend on the pluralization
|
||||
# rules for the locale, as defined in the CLDR.
|
||||
# As of v41, 6 locale-specific plural categories are defined:
|
||||
# :few, :many, :one, :other, :two, :zero
|
||||
#
|
||||
# n.b., The :one plural category does not imply the number 1.
|
||||
# Instead, :one is a category for any number that behaves like 1 in
|
||||
# that locale. For example, in some locales, :one is used for numbers
|
||||
# that end in "1" (like 1, 21, 151) but that don't end in
|
||||
# 11 (like 11, 111, 10311).
|
||||
# Similar notes apply to the :two, and :zero plural categories.
|
||||
#
|
||||
# If you want to have different strings for the categories of count == 0
|
||||
# (e.g. "I don't have any cars") or count == 1 (e.g. "I have a single car")
|
||||
# use the explicit `"0"` and `"1"` keys.
|
||||
# https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#Explicit_0_1_rules
|
||||
def pluralize(locale, entry, count)
|
||||
return entry unless entry.is_a?(Hash) && count
|
||||
|
||||
pluralizer = pluralizer(locale)
|
||||
if pluralizer.respond_to?(:call)
|
||||
# Deprecation: The use of the `zero` key in this way is incorrect.
|
||||
# Users that want a different string for the case of `count == 0` should use the explicit "0" key instead.
|
||||
# We keep this incorrect behaviour for now for backwards compatibility until we can remove it.
|
||||
# Ref: https://github.com/ruby-i18n/i18n/issues/629
|
||||
return entry[:zero] if count == 0 && entry.has_key?(:zero)
|
||||
|
||||
# "0" and "1" are special cases
|
||||
# https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#Explicit_0_1_rules
|
||||
if count == 0 || count == 1
|
||||
value = entry[symbolic_count(count)]
|
||||
return value if value
|
||||
end
|
||||
|
||||
# Lateral Inheritance of "count" attribute (http://www.unicode.org/reports/tr35/#Lateral_Inheritance):
|
||||
# > If there is no value for a path, and that path has a [@count="x"] attribute and value, then:
|
||||
# > 1. If "x" is numeric, the path falls back to the path with [@count=«the plural rules category for x for that locale»], within that the same locale.
|
||||
# > 2. If "x" is anything but "other", it falls back to a path [@count="other"], within that the same locale.
|
||||
# > 3. If "x" is "other", it falls back to the path that is completely missing the count item, within that the same locale.
|
||||
# Note: We don't yet implement #3 above, since we haven't decided how lateral inheritance attributes should be represented.
|
||||
plural_rule_category = pluralizer.call(count)
|
||||
|
||||
value = if entry.has_key?(plural_rule_category) || entry.has_key?(:other)
|
||||
entry[plural_rule_category] || entry[:other]
|
||||
else
|
||||
raise InvalidPluralizationData.new(entry, count, plural_rule_category)
|
||||
end
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def pluralizers
|
||||
@pluralizers ||= {}
|
||||
end
|
||||
|
||||
def pluralizer(locale)
|
||||
pluralizers[locale] ||= I18n.t(:'i18n.plural.rule', :locale => locale, :resolve => false)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Normalizes categories of 0.0 and 1.0
|
||||
# and returns the symbolic version
|
||||
def symbolic_count(count)
|
||||
count = 0 if count == 0
|
||||
count = 1 if count == 1
|
||||
count.to_s.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -21,6 +21,9 @@ module I18n
|
||||
class Simple
|
||||
module Implementation
|
||||
include Base
|
||||
|
||||
# Mutex to ensure that concurrent translations loading will be thread-safe
|
||||
MUTEX = Mutex.new
|
||||
|
||||
def initialized?
|
||||
@initialized ||= false
|
||||
@ -68,7 +71,11 @@ module I18n
|
||||
# call `init_translations`
|
||||
init_translations if do_init && !initialized?
|
||||
|
||||
@translations ||= Concurrent::Hash.new { |h, k| h[k] = Concurrent::Hash.new }
|
||||
@translations ||= Concurrent::Hash.new do |h, k|
|
||||
MUTEX.synchronize do
|
||||
h[k] = Concurrent::Hash.new
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
@ -94,7 +101,7 @@ module I18n
|
||||
return nil unless result.has_key?(_key)
|
||||
end
|
||||
result = result[_key]
|
||||
result = resolve_entry(locale, _key, result, options.merge(:scope => nil)) if result.is_a?(Symbol)
|
||||
result = resolve_entry(locale, _key, result, Utils.except(options.merge(:scope => nil), :count)) if result.is_a?(Symbol)
|
||||
result
|
||||
end
|
||||
end
|
||||
@ -45,30 +45,30 @@ module I18n
|
||||
"Ç"=>"C", "È"=>"E", "É"=>"E", "Ê"=>"E", "Ë"=>"E", "Ì"=>"I", "Í"=>"I",
|
||||
"Î"=>"I", "Ï"=>"I", "Ð"=>"D", "Ñ"=>"N", "Ò"=>"O", "Ó"=>"O", "Ô"=>"O",
|
||||
"Õ"=>"O", "Ö"=>"O", "×"=>"x", "Ø"=>"O", "Ù"=>"U", "Ú"=>"U", "Û"=>"U",
|
||||
"Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "à"=>"a", "á"=>"a", "â"=>"a",
|
||||
"ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c", "è"=>"e", "é"=>"e",
|
||||
"ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i", "ï"=>"i", "ð"=>"d",
|
||||
"ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o", "ö"=>"o", "ø"=>"o",
|
||||
"ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y", "þ"=>"th", "ÿ"=>"y",
|
||||
"Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A", "ą"=>"a", "Ć"=>"C",
|
||||
"ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c", "Č"=>"C", "č"=>"c",
|
||||
"Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E", "ē"=>"e", "Ĕ"=>"E",
|
||||
"ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e", "Ě"=>"E", "ě"=>"e",
|
||||
"Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G", "ġ"=>"g", "Ģ"=>"G",
|
||||
"ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h", "Ĩ"=>"I", "ĩ"=>"i",
|
||||
"Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I", "į"=>"i", "İ"=>"I",
|
||||
"ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j", "Ķ"=>"K", "ķ"=>"k",
|
||||
"ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l", "Ľ"=>"L", "ľ"=>"l",
|
||||
"Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N", "ń"=>"n", "Ņ"=>"N",
|
||||
"ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG", "ŋ"=>"ng",
|
||||
"Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o", "Œ"=>"OE",
|
||||
"œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R", "ř"=>"r",
|
||||
"Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s", "Š"=>"S",
|
||||
"š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T", "ŧ"=>"t",
|
||||
"Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u", "Ů"=>"U",
|
||||
"ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W", "ŵ"=>"w",
|
||||
"Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z", "ż"=>"z",
|
||||
"Ž"=>"Z", "ž"=>"z"
|
||||
"Ü"=>"U", "Ý"=>"Y", "Þ"=>"Th", "ß"=>"ss", "ẞ"=>"SS", "à"=>"a",
|
||||
"á"=>"a", "â"=>"a", "ã"=>"a", "ä"=>"a", "å"=>"a", "æ"=>"ae", "ç"=>"c",
|
||||
"è"=>"e", "é"=>"e", "ê"=>"e", "ë"=>"e", "ì"=>"i", "í"=>"i", "î"=>"i",
|
||||
"ï"=>"i", "ð"=>"d", "ñ"=>"n", "ò"=>"o", "ó"=>"o", "ô"=>"o", "õ"=>"o",
|
||||
"ö"=>"o", "ø"=>"o", "ù"=>"u", "ú"=>"u", "û"=>"u", "ü"=>"u", "ý"=>"y",
|
||||
"þ"=>"th", "ÿ"=>"y", "Ā"=>"A", "ā"=>"a", "Ă"=>"A", "ă"=>"a", "Ą"=>"A",
|
||||
"ą"=>"a", "Ć"=>"C", "ć"=>"c", "Ĉ"=>"C", "ĉ"=>"c", "Ċ"=>"C", "ċ"=>"c",
|
||||
"Č"=>"C", "č"=>"c", "Ď"=>"D", "ď"=>"d", "Đ"=>"D", "đ"=>"d", "Ē"=>"E",
|
||||
"ē"=>"e", "Ĕ"=>"E", "ĕ"=>"e", "Ė"=>"E", "ė"=>"e", "Ę"=>"E", "ę"=>"e",
|
||||
"Ě"=>"E", "ě"=>"e", "Ĝ"=>"G", "ĝ"=>"g", "Ğ"=>"G", "ğ"=>"g", "Ġ"=>"G",
|
||||
"ġ"=>"g", "Ģ"=>"G", "ģ"=>"g", "Ĥ"=>"H", "ĥ"=>"h", "Ħ"=>"H", "ħ"=>"h",
|
||||
"Ĩ"=>"I", "ĩ"=>"i", "Ī"=>"I", "ī"=>"i", "Ĭ"=>"I", "ĭ"=>"i", "Į"=>"I",
|
||||
"į"=>"i", "İ"=>"I", "ı"=>"i", "IJ"=>"IJ", "ij"=>"ij", "Ĵ"=>"J", "ĵ"=>"j",
|
||||
"Ķ"=>"K", "ķ"=>"k", "ĸ"=>"k", "Ĺ"=>"L", "ĺ"=>"l", "Ļ"=>"L", "ļ"=>"l",
|
||||
"Ľ"=>"L", "ľ"=>"l", "Ŀ"=>"L", "ŀ"=>"l", "Ł"=>"L", "ł"=>"l", "Ń"=>"N",
|
||||
"ń"=>"n", "Ņ"=>"N", "ņ"=>"n", "Ň"=>"N", "ň"=>"n", "ʼn"=>"'n", "Ŋ"=>"NG",
|
||||
"ŋ"=>"ng", "Ō"=>"O", "ō"=>"o", "Ŏ"=>"O", "ŏ"=>"o", "Ő"=>"O", "ő"=>"o",
|
||||
"Œ"=>"OE", "œ"=>"oe", "Ŕ"=>"R", "ŕ"=>"r", "Ŗ"=>"R", "ŗ"=>"r", "Ř"=>"R",
|
||||
"ř"=>"r", "Ś"=>"S", "ś"=>"s", "Ŝ"=>"S", "ŝ"=>"s", "Ş"=>"S", "ş"=>"s",
|
||||
"Š"=>"S", "š"=>"s", "Ţ"=>"T", "ţ"=>"t", "Ť"=>"T", "ť"=>"t", "Ŧ"=>"T",
|
||||
"ŧ"=>"t", "Ũ"=>"U", "ũ"=>"u", "Ū"=>"U", "ū"=>"u", "Ŭ"=>"U", "ŭ"=>"u",
|
||||
"Ů"=>"U", "ů"=>"u", "Ű"=>"U", "ű"=>"u", "Ų"=>"U", "ų"=>"u", "Ŵ"=>"W",
|
||||
"ŵ"=>"w", "Ŷ"=>"Y", "ŷ"=>"y", "Ÿ"=>"Y", "Ź"=>"Z", "ź"=>"z", "Ż"=>"Z",
|
||||
"ż"=>"z", "Ž"=>"Z", "ž"=>"z"
|
||||
}.freeze
|
||||
|
||||
def initialize(rule = nil)
|
||||
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# heavily based on Masao Mutoh's gettext String interpolation extension
|
||||
# http://github.com/mutoh/gettext/blob/f6566738b981fe0952548c421042ad1e0cdfb31e/lib/gettext/core_ext/string.rb
|
||||
|
||||
@ -10,6 +12,11 @@ module I18n
|
||||
INTERPOLATION_PATTERN = Regexp.union(DEFAULT_INTERPOLATION_PATTERNS)
|
||||
deprecate_constant :INTERPOLATION_PATTERN
|
||||
|
||||
INTERPOLATION_PATTERNS_CACHE = Hash.new do |hash, patterns|
|
||||
hash[patterns] = Regexp.union(patterns)
|
||||
end
|
||||
private_constant :INTERPOLATION_PATTERNS_CACHE
|
||||
|
||||
class << self
|
||||
# Return String or raises MissingInterpolationArgument exception.
|
||||
# Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler.
|
||||
@ -20,7 +27,12 @@ module I18n
|
||||
end
|
||||
|
||||
def interpolate_hash(string, values)
|
||||
string.gsub(Regexp.union(config.interpolation_patterns)) do |match|
|
||||
pattern = INTERPOLATION_PATTERNS_CACHE[config.interpolation_patterns]
|
||||
interpolated = false
|
||||
|
||||
interpolated_string = string.gsub(pattern) do |match|
|
||||
interpolated = true
|
||||
|
||||
if match == '%%'
|
||||
'%'
|
||||
else
|
||||
@ -34,6 +46,8 @@ module I18n
|
||||
$3 ? sprintf("%#{$3}", value) : value
|
||||
end
|
||||
end
|
||||
|
||||
interpolated ? interpolated_string : string
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module I18n
|
||||
VERSION = "1.12.0"
|
||||
VERSION = "1.13.0"
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user