Method: I18n::Inflector::InflectionData#get_true_token

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

#get_true_token(token) ⇒ Symbol? #get_true_token(token, kind) ⇒ Symbol?

Note:

If the given token is really an alias it will be resolved and the real token pointed by that alias will be returned.

Gets a true token for the given identifier.

Overloads:

  • #get_true_token(token) ⇒ Symbol?

    Gets a true token for the given token identifier.

    Parameters:

    • token (Symbol)

      the identifier of a token

    Returns:

    • (Symbol, nil)

      the true token for the given token or nil if the token is unknown

  • #get_true_token(token, kind) ⇒ Symbol?

    Gets a true token for the given token identifier and the given kind. The kind will work as the expectation filter.

    Parameters:

    • token (Symbol)

      the identifier of a token

    • kind (Symbol)

      the identifier of a kind

    Returns:

    • (Symbol, nil)

      the true token for the given token or nil if the token is unknown or is not a kind of the given kind

Returns:

  • (Symbol, nil)

    the true token for the given token or nil

[View source]

311
312
313
314
315
316
317
318
# File 'lib/i18n-inflector/inflection_data.rb', line 311

def get_true_token(token, kind=nil)
  o = @tokens[token]
  k = o[:kind]
  return nil if k.nil?
  r = (o[:target] || token)
  return r if kind.nil?
  k == kind ? r : nil
end