Module: I18nAccessors

Defined in:
lib/i18n_accessors.rb,
lib/i18n_accessors/methods.rb,
lib/i18n_accessors/missing.rb,
lib/i18n_accessors/version.rb

Defined Under Namespace

Classes: Configuration, Methods, Missing

Constant Summary collapse

VERSION =
"1.0.0"

Configuration Methods collapse

Class Method Summary collapse

Class Method Details

.configI18nAccessors::Configuration

Returns I18nAccessors configuration.

Returns:



16
17
18
# File 'lib/i18n_accessors.rb', line 16

def config
  @configuration ||= Configuration.new
end

.configure {|I18nAccessors::Configuration| ... } ⇒ Object

Configure I18nAccessors

Yields:



10
11
12
# File 'lib/i18n_accessors.rb', line 10

def configure
  yield config
end

.i18n_classClass

Returns I18n Class to use for setting locale.

Returns:

  • (Class)

    I18n Class to use for setting locale



21
22
23
# File 'lib/i18n_accessors.rb', line 21

def i18n_class
  config.i18n_class
end

.normalize_locale(locale = I18n.locale) ⇒ String

Return normalized locale

Examples:

I18nAccessors.normalize_locale(:ja)
#=> "ja"
I18nAccessors.normalize_locale("pt-BR")
#=> "pt_br"

Parameters:

  • locale (String, Symbol) (defaults to: I18n.locale)

Returns:

  • (String)

    Normalized locale



33
34
35
# File 'lib/i18n_accessors.rb', line 33

def normalize_locale(locale = I18n.locale)
  "#{locale.to_s.downcase.sub("-", "_")}".freeze
end