Module: I18n

Defined in:
lib/gettext_i18n_rails/i18n_hacks.rb

Defined Under Namespace

Classes: Config

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.localeObject



8
9
10
# File 'lib/gettext_i18n_rails/i18n_hacks.rb', line 8

def locale
  FastGettext.locale.to_sym
end

.locale=(new_locale) ⇒ Object



4
5
6
# File 'lib/gettext_i18n_rails/i18n_hacks.rb', line 4

def locale=(new_locale)
  FastGettext.locale = new_locale
end

Instance Method Details

#with_locale(tmp_locale = nil) ⇒ Object

Executes block with given I18n.locale set.



28
29
30
31
32
33
34
35
36
# File 'lib/gettext_i18n_rails/i18n_hacks.rb', line 28

def with_locale(tmp_locale = nil)
  if tmp_locale
    current_locale = self.locale
    self.locale = tmp_locale
  end
  yield
ensure
  self.locale = current_locale if tmp_locale
end