lib/refinery/i18n.rb in refinerycms-i18n-0.9.9.16 vs lib/refinery/i18n.rb in refinerycms-i18n-1.0.0
- old
+ new
@@ -18,30 +18,31 @@
initializer "serve static assets" do |app|
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
end
config.to_prepare do
- ::ApplicationController.class_eval do
+ ::ApplicationController.module_eval do
before_filter lambda {|c|
::SimplesIdeias::I18n.export! if Rails.env.development?
}
def default_url_options(options={})
::Refinery::I18n.enabled? ? { :locale => ::I18n.locale } : {}
end
def find_or_set_locale
if ::Refinery::I18n.enabled?
- ::I18n.locale = ::Refinery::I18n.current_locale
+ ::I18n.locale = ::Refinery::I18n.current_frontend_locale
if ::Refinery::I18n.has_locale?(locale = params[:locale].try(:to_sym))
::I18n.locale = locale
elsif locale.present? and locale != ::Refinery::I18n.default_frontend_locale
params[:locale] = ::I18n.locale = ::Refinery::I18n.default_frontend_locale
redirect_to(params, :notice => "The locale '#{locale}' is not supported.") and return
else
::I18n.locale = ::Refinery::I18n.default_frontend_locale
end
+ Thread.current[:globalize_locale] = ::I18n.locale
end
end
prepend_before_filter :find_or_set_locale
protected :default_url_options, :find_or_set_locale