Method: I18n::Inflector::API_Strict#prep_locale

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

#prep_locale(locale = nil) ⇒ Symbol (protected)

Note:

If the locale is not correct, it tries to use locale from I18n.locale and validates it as well.

Processes locale identifier and validates whether it’s correct (not empty and not nil).

Parameters:

  • locale (Symbol, String) (defaults to: nil)

    the locale identifier

Returns:

  • (Symbol)

    the given locale or the global locale

Raises:


653
654
655
656
657
# File 'lib/i18n-inflector/api_strict.rb', line 653

def prep_locale(locale=nil)
  locale ||= I18n.locale
  raise I18n::InvalidLocale.new(locale) if locale.to_s.empty?
  locale.to_sym
end