Method: I18n::Inflector::InflectionData_Strict#add_alias

Defined in:
lib/i18n-inflector/inflection_data_strict.rb

#add_alias(name, target, kind) ⇒ Boolean

Adds an alias (overwriting existing alias).

Parameters:

  • name (Symbol)

    the name of an alias

  • target (Symbol)

    the target token for the created alias

  • kind (Symbol)

    the identifier of a kind

Returns:

  • (Boolean)

    true if everything went ok, false otherwise (in case of bad names or non-existent targets)


54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/i18n-inflector/inflection_data_strict.rb', line 54

def add_alias(name, target, kind)
  return false if (name.nil? || target.nil? || kind.nil?)
  return false if (name.to_s.empty? || target.to_s.empty? || kind.to_s.empty?)
  name    = name.to_sym
  target  = target.to_sym
  kind    = kind.to_sym
  k       = @tokens[kind]
  return false unless k.has_key?(target)
  token               = k[name] = {}
  token[:description] = k[target][:description]
  token[:target]      = target
  true
end