module I18n

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/i18n.rbs

module I18n
  def fallbacks: () -> untyped
  def interpolate: (String string, Hash values) -> untyped
  def interpolate_hash: (String string, Hash values) -> untyped
end

def self.new_double_nested_cache # :nodoc:

:nodoc:
def self.new_double_nested_cache # :nodoc:
  Concurrent::Map.new { |h, k| h[k] = Concurrent::Map.new }
end

def self.reserve_key(key)

before any I18n.translate (etc) calls are made.
extra keys as I18n options, you should call I18n.reserve_key
and can't also be used for interpolation. If you are using any
Marks a key as reserved. Reserved keys are used internally,
def self.reserve_key(key)
  RESERVED_KEYS << key.to_sym
  @reserved_keys_pattern = nil
end

def self.reserved_keys_pattern # :nodoc:

:nodoc:
def self.reserved_keys_pattern # :nodoc:
  @reserved_keys_pattern ||= /%\{(#{RESERVED_KEYS.join("|")})\}/
end

def cache_key_digest

def cache_key_digest
  @@cache_key_digest
end

def cache_key_digest=(key_digest)

def cache_key_digest=(key_digest)
  @@cache_key_digest = key_digest
end

def cache_namespace

def cache_namespace
  @@cache_namespace
end

def cache_namespace=(namespace)

def cache_namespace=(namespace)
  @@cache_namespace = namespace
end

def cache_store

def cache_store
  @@cache_store
end

def cache_store=(store)

def cache_store=(store)
  @@cache_store = store
end

def fallbacks

Experimental RBS support (using type sampling data from the type_fusion project).

def fallbacks: () -> untyped

This signature was generated using 59 samples from 1 application.

Returns the current fallbacks implementation. Defaults to +I18n::Locale::Fallbacks+.
def fallbacks
  @@fallbacks ||= I18n::Locale::Fallbacks.new
  Thread.current[:i18n_fallbacks] || @@fallbacks
end

def fallbacks=(fallbacks)

Sets the current fallbacks implementation. Use this to set a different fallbacks implementation.
def fallbacks=(fallbacks)
  @@fallbacks = fallbacks.is_a?(Array) ? I18n::Locale::Fallbacks.new(fallbacks) : fallbacks
  Thread.current[:i18n_fallbacks] = @@fallbacks
end

def interpolate(string, values)

Experimental RBS support (using type sampling data from the type_fusion project).

def interpolate: (String string, count | Integer | base | User values) -> untyped

This signature was generated using 1 sample from 1 application.

Missing argument's logic is handled by I18n.config.missing_interpolation_argument_handler.
Return String or raises MissingInterpolationArgument exception.
def interpolate(string, values)
  raise ReservedInterpolationKey.new($1.to_sym, string) if string =~ I18n.reserved_keys_pattern
  raise ArgumentError.new('Interpolation values must be a Hash.') unless values.kind_of?(Hash)
  interpolate_hash(string, values)
end

def interpolate_hash(string, values)

Experimental RBS support (using type sampling data from the type_fusion project).

def interpolate_hash: (String string, (count | Integer | model | String | attribute | String | value | NilClass) values) -> untyped

This signature was generated using 3 samples from 1 application.

def interpolate_hash(string, values)
  pattern = INTERPOLATION_PATTERNS_CACHE[config.interpolation_patterns]
  interpolated = false
  interpolated_string = string.gsub(pattern) do |match|
    interpolated = true
    if match == '%%'
      '%'
    else
      key = ($1 || $2 || match.tr("%{}", "")).to_sym
      value = if values.key?(key)
                values[key]
              else
                config.missing_interpolation_argument_handler.call(key, values, string)
              end
      value = value.call(values) if value.respond_to?(:call)
      $3 ? sprintf("%#{$3}", value) : value
    end
  end
  interpolated ? interpolated_string : string
end

def perform_caching?

def perform_caching?
  !cache_store.nil?
end