diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 22 | ||||
-rw-r--r-- | app/helpers/navigation_helper.rb | 3 |
2 files changed, 14 insertions, 11 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 diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index a43eecd..fde6b45 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -1,7 +1,7 @@ module NavigationHelper def has_side_column? - if root_page? + if root_page? || site.menu.nil? return false end second_level_children_count = site.menu.submenu(current_page_path.first).try(:size) @@ -13,6 +13,7 @@ module NavigationHelper end def top_level_navigation_links + return unless site.menu haml do first = 'first' site.menu.each do |item| |