module Sinatra::R18n
Public Class Methods
registered(app)
click to toggle source
# File lib/sinatra/r18n.rb, line 25 def self.registered(app) app.helpers ::R18n::Helpers app.set :default_locale, Proc.new { ::R18n::I18n.default } app.set :translations, Proc.new { ::R18n.default_places } ::R18n.default_places { File.join(app.root, 'i18n/') } app.before do ::R18n.clear_cache! if self.class.development? ::R18n.thread_set do if settings.default_locale ::R18n::I18n.default = settings.default_locale end locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE']) if params[:locale] locales.insert(0, params[:locale]) elsif session[:locale] locales.insert(0, session[:locale]) end ::R18n::I18n.new(locales, ::R18n.default_places, off_filters: :untranslated, on_filters: :untranslated_html) end end end