Module: Lazier::I18n

Included in:
Settings
Defined in:
lib/lazier/i18n.rb

Overview

Provides an easy way to localized messages in a class.

Instance Method Summary collapse

Instance Method Details

#i18nR18N::Translation

Get the list of available translation for the current locale.

Returns:

  • (R18N::Translation)

    The translation object.



22
23
24
# File 'lib/lazier/i18n.rb', line 22

def i18n
  @i18n ||= i18n_load_locale(nil)
end

#i18n=(locale) ⇒ R18n::Translation

Set the current locale for messages.

Parameters:

  • locale (String)

    The new locale. Default is the current system locale.

Returns:

  • (R18n::Translation)

    The new translation object.



30
31
32
# File 'lib/lazier/i18n.rb', line 30

def i18n=(locale)
  @i18n = i18n_load_locale(locale)
end

#i18n_setup(root, path) ⇒ Object

Setup all I18n translations.

Parameters:

  • root (Symbol)

    The root level of translation.

  • path (String)

    The path where the translation are stored.



14
15
16
17
# File 'lib/lazier/i18n.rb', line 14

def i18n_setup(root, path)
  @i18n_root = root.to_sym
  @i18n_locales_path = path
end