From e1e5b15db0d1e5e76d3999a46b609b2c89715df0 Mon Sep 17 00:00:00 2001
From: Thomas Lecavelier
Date: Mon, 30 Nov 2009 13:14:03 +0100
Subject: [PATCH] Redmine default locale used before browser locale, enable setting
default_locale to auto, so the user browser HTTP_ACCEPT_LANGUAGE take
precedence.
---
app/controllers/application_controller.rb | 4 ++--
app/views/settings/_display.rhtml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a794b3b..e2a4941 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -95,13 +95,13 @@ class ApplicationController < ActionController::Base
if User.current.logged?
lang = find_language(User.current.language)
end
- if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
+ lang ||= Setting.default_language
+ if lang.blank? && request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
if !accept_lang.blank?
lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
end
end
- lang ||= Setting.default_language
set_language_if_valid(lang)
end
diff --git a/app/views/settings/_display.rhtml b/app/views/settings/_display.rhtml
index 351760f..65117d3 100644
--- a/app/views/settings/_display.rhtml
+++ b/app/views/settings/_display.rhtml
@@ -5,7 +5,7 @@
<%= select_tag 'settings[ui_theme]', options_for_select( ([[l(:label_default), '']] + Redmine::Themes.themes.collect {|t| [t.name, t.id]}), Setting.ui_theme) %>
-<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %>
+<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(true), Setting.default_language) %>
<%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '']] + Setting::DATE_FORMATS.collect {|f| [Date.today.strftime(f), f]}, Setting.date_format) %>
--
1.6.3.3