Project

General

Profile

Defect #4311 » 0001-Redmine-default-locale-used-before-browser-locale-en.patch

Take 2: enable "auto" to use browser HTTP_ACCEPTED_LANGUAGE - Thomas Lecavelier, 2009-12-01 08:52

View differences:

app/controllers/application_controller.rb
95 95
    if User.current.logged?
96 96
      lang = find_language(User.current.language)
97 97
    end
98
    if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
98
    lang ||= Setting.default_language
99
    if lang.blank? && request.env['HTTP_ACCEPT_LANGUAGE']
99 100
      accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
100 101
      if !accept_lang.blank?
101 102
        lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
102 103
      end
103 104
    end
104
    lang ||= Setting.default_language
105 105
    set_language_if_valid(lang)
106 106
  end
107 107
  
app/views/settings/_display.rhtml
5 5
<%= select_tag 'settings[ui_theme]', options_for_select( ([[l(:label_default), '']] + Redmine::Themes.themes.collect {|t| [t.name, t.id]}), Setting.ui_theme) %></p>
6 6

  
7 7
<p><label><%= l(:setting_default_language) %></label>
8
<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
8
<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(true), Setting.default_language) %></p>
9 9

  
10 10
<p><label><%= l(:setting_date_format) %></label>
11 11
<%= 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) %></p>
(2-2/2)