diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2011-03-25 15:20:59 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2011-03-25 15:20:59 +0000 |
commit | 2bb79f893805e972f6efe5cb7cfe90dd0efa4107 (patch) | |
tree | 47084acc8d48126b9e891bb50c217be43be27641 /app/controllers/application_controller.rb | |
parent | 22c25e42847d41924d43d31f3ef67be1ae4a155e (diff) | |
parent | 1fb57d66c22000d4164c033ffd9353aa9030255b (diff) |
resolve merge conflicts
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9382e077f..91754e2ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,11 +12,28 @@ class ApplicationController < ActionController::Base # Standard headers, footers and navigation for whole site layout "default" - # set locale + include FastGettext::Translation # make functions like _, n_, N_ etc available) before_filter :set_gettext_locale + + # scrub sensitive parameters from the logs + filter_parameter_logging :password + + + def set_gettext_locale + requested_locale = params[:locale] || session[:locale] || cookies[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] + session[:locale] = FastGettext.set_locale(requested_locale) + end + # scrub sensitive parameters from the logs filter_parameter_logging :password + helper_method :site_name, :locale_from_params + def site_name + # XXX should come from database: + site_name = "WhatDoTheyKnow" + return site_name + end + # Help work out which request causes RAM spike. # http://www.codeweblog.com/rails-to-monitor-the-process-of-memory-leaks-skills/ # This shows the memory use increase of the Ruby process due to the request. @@ -131,6 +148,16 @@ class ApplicationController < ActionController::Base f.write(content) end end + + # get the local locale + def locale_from_params(*args) + if params[:show_locale] + params[:show_locale] + else + I18n.locale.to_s + end + end + private # Check the user is logged in |