Module: SimpleLocalizer

Defined in:
lib/simple_localizer.rb,
lib/generators/simple_localizer/create_migration_generator.rb

Defined Under Namespace

Modules: ClassMethods, Generators

Constant Summary collapse

@@supported_locales =
%w(
  aa ab ae af al am ar as ay az
  ba be bg bh bi bn bo bp br ca
  cf ch co cs cy de dr dt dz ef
  eg ej el en eo ep er es et eu
  fa fi fj fo fr fy ga gd gl gn
  gu ha he hi hm hr hu hy ia ie
  ik in is it iw ja ji jv ka kk
  kl km kn ko ks ku ky la ln lo
  lt lv mg mi mk ml mn mo mr ms
  mt my na ne nl no nt oc of og
  om or pa pl pn ps pt qu re rm
  rn ro ru rw sa sd sf sg sh si
  sk sl sm sn so sq sr ss st su
  sv sw ta te tg th ti tj tk tl
  tn to tp tr ts tt tw uk ul ur
  uz vi vo wo xh yo zh zu
)

Class Method Summary collapse

Class Method Details

.read_localeObject



116
117
118
# File 'lib/simple_localizer.rb', line 116

def read_locale
  (Thread.current[:simple_localizer_locale] || I18n.locale || I18n.default_locale).to_s
end

.supported_localesObject



98
99
100
# File 'lib/simple_localizer.rb', line 98

def supported_locales
  @@supported_locales
end

.supported_locales=(value) ⇒ Object



102
103
104
# File 'lib/simple_localizer.rb', line 102

def supported_locales=(value)
  @@supported_locales = value
end

.with_locale(new_locale, &block) ⇒ Object



106
107
108
109
110
111
112
113
114
# File 'lib/simple_localizer.rb', line 106

def with_locale(new_locale, &block)
  begin
    pre_locale = Thread.current[:simple_localizer_locale]
    set_locale(new_locale)
    yield
  ensure
    set_locale(pre_locale)
  end
end