From ea5f89e55c7afde4bf2d6719b0afa8a878082fb5 Mon Sep 17 00:00:00 2001 From: elijah Date: Tue, 12 Feb 2013 23:46:35 -0800 Subject: misc fixes to get working in production mode using Thin. --- app/controllers/application_controller.rb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'app/controllers/application_controller.rb') 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 -- cgit v1.2.3