diff options
author | elijah <elijah@riseup.net> | 2013-02-12 23:46:35 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-02-12 23:46:35 -0800 |
commit | ea5f89e55c7afde4bf2d6719b0afa8a878082fb5 (patch) | |
tree | b1c974ca423c52a03724f39035fa2a49775acd5c /app/controllers/application_controller.rb | |
parent | e29134d17854d88b4a81456987c28db93f5ec97c (diff) |
misc fixes to get working in production mode using Thin.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b2c5762..b73a463 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,18 +22,20 @@ class ApplicationController < ActionController::Base # ensure that the locale is encoded as the url prefix and I18n.locale is set. # def set_locale - if params[:locale].nil? || !AVAILABLE_LANGUAGES.include?(params[:locale]) - locale = HttpAcceptLanguage::compatible_language_from(request.headers['HTTP_ACCEPT_LANGUAGE'], AVAILABLE_LANGUAGES) || DEFAULT_LOCALE - locale = locale.to_s.sub('-', '_').sub(/_\w\w/, '') - if request.path == '/' - url = '/' + locale + if request.format == 'text/html' + if params[:locale].nil? || !AVAILABLE_LANGUAGES.include?(params[:locale]) + locale = HttpAcceptLanguage::compatible_language_from(request.headers['HTTP_ACCEPT_LANGUAGE'], AVAILABLE_LANGUAGES) || DEFAULT_LOCALE + locale = locale.to_s.sub('-', '_').sub(/_\w\w/, '') + if request.path == '/' + url = '/' + locale + else + url = url_for(params.merge(:locale => locale)) + end + redirect_to url else - url = url_for(params.merge(:locale => locale)) + I18n.locale = params[:locale] + self.default_url_options[:locale] = params[:locale] end - redirect_to url - else - I18n.locale = params[:locale] - self.default_url_options[:locale] = params[:locale] end end |