Project

General

Profile

Feature #2691 » option_to_disable_language_guessing-r2383.patch

Patch created against trunk@r2383. - Mischa The Evil, 2009-02-07 00:28

View differences:

app/controllers/application.rb (working copy)
65 65
  
66 66
  def set_localization
67 67
    User.current.language = nil unless User.current.logged?
68
    lang = begin
69
      if !User.current.language.blank? && GLoc.valid_language?(User.current.language)
70
        User.current.language
71
      elsif request.env['HTTP_ACCEPT_LANGUAGE']
72
        accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
73
        if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first))
74
          User.current.language = accept_lang
75
        end
76
      end
77
    rescue
78
      nil
79
    end || Setting.default_language
80
    set_language_if_valid(lang)    
68
    if !Setting.static_language?
69
        lang = begin
70
          if !User.current.language.blank? && GLoc.valid_language?(User.current.language)
71
            User.current.language
72
          elsif request.env['HTTP_ACCEPT_LANGUAGE']
73
            accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first.downcase
74
            if !accept_lang.blank? && (GLoc.valid_language?(accept_lang) || GLoc.valid_language?(accept_lang = accept_lang.split('-').first))
75
              User.current.language = accept_lang
76
            end
77
          end
78
        rescue
79
          nil
80
        end || Setting.default_language
81
        set_language_if_valid(lang)
82
    else
83
        lang = Setting.default_language
84
    end
81 85
  end
82 86
  
83 87
  def require_login
app/views/settings/_display.rhtml (working copy)
7 7
<p><label><%= l(:setting_default_language) %></label>
8 8
<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
9 9

  
10
<p><label><%= l(:setting_static_language) %></label>
11
<%= check_box_tag 'settings[static_language]', 1, Setting.static_language? %><%= hidden_field_tag 'settings[static_language]', 0 %></p>
12

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

  
config/settings.yml (working copy)
143 143
    To change your notification preferences, please click here: http://hostname/my/account
144 144
gravatar_enabled:  
145 145
  default: 0
146
static_language:
147
  default: 0
lang/en.yml (working copy)
228 228
setting_gravatar_enabled: Use Gravatar user icons
229 229
setting_diff_max_lines_displayed: Max number of diff lines displayed
230 230
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
231
setting_static_language: Disable automated language-guessing based on HTTP_ACCEPT_LANGUAGE HTTP-header
231 232

  
232 233
permission_edit_project: Edit project
233 234
permission_select_project_modules: Select project modules
(1-1/3)