Module: Sinatra::I18n
- Defined in:
- lib/sinatra/i18n.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/sinatra/i18n.rb', line 108 def self.registered(app) app.helpers I18n::Helpers app.before do #$log.info("Sesion es:#{session['language']}") if session['language'].nil? language=get_lang(request.env['HTTP_ACCEPT_LANGUAGE']) #$log.info("Desde HTTP:#{language}") language='en' unless ['en','es','pl'].include? language ::I18n.locale = language else ::I18n.locale = session['language'].to_sym end end #$log.info(app.root) unless defined?(app.locales) app.set :locales, File.join(app.root, 'config','locales', '*.yml') end ::I18n.load_path+=Dir[app.locales] ::I18n.config.available_locales = [:es,:en,:pl] ::I18n.default_locale=:en #::I18n.backend.load_translations(app.locales) end |