Module: Snails::Locales

Defined in:
lib/snails/app.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/snails/app.rb', line 39

def self.registered(app)
  require 'i18n'
  require 'i18n/backend/fallbacks'

  cwd = Pathname.new(Dir.pwd)
  app.set :locale, :es
  app.set :locales_path, cwd.join('config', 'locales')

  app.helpers do
    def t(key); I18n.t(key); end
  end

  app.configure do
    I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
    I18n.load_path = Dir[File.join(app.settings.locales_path, '*.yml')]
    I18n.enforce_available_locales = false
    I18n.backend.load_translations
  end

  app.before do
    I18n.locale = app.settings.locale
  end
end