if User.current.logged?
lang = find_language(User.current.language)
end
- if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE']
+ if lang.nil? && !Setting.force_default_language_for_anonymous? && request.env['HTTP_ACCEPT_LANGUAGE']
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
if !accept_lang.blank?
accept_lang = accept_lang.downcase
def setting_label(setting, options={})
label = options.delete(:label)
- label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}")).html_safe : ''
+ label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}"), options[:label_options]).html_safe : ''
end
# Renders a notification field for a Redmine::Notifiable option
@time_zone ||= (self.pref.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.pref.time_zone])
end
+ def force_default_language?
+ Setting.force_default_language_for_loggedin?
+ end
+
+ def language
+ if force_default_language?
+ Setting.default_language
+ else
+ super
+ end
+ end
+
def wants_comments_in_reverse_order?
self.pref[:comments_sorting] == 'desc'
end
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
+
+<% unless @user.force_default_language? %>
<p><%= f.select :language, lang_options_for_select %></p>
+<% end %>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
+ <% unless @user.force_default_language? %>
<p><%= f.select :language, lang_options_for_select %></p>
+ <% end %>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<% end %>
<p><%= setting_select :default_language, lang_options_for_select(false) %></p>
+<p><%= setting_check_box :force_default_language_for_anonymous %></p>
+
+<p><%= setting_check_box :force_default_language_for_loggedin %></p>
+
<p><%= setting_select :start_of_week, [[day_name(1),'1'], [day_name(6),'6'], [day_name(7),'7']], :blank => :label_language_based %></p>
<% locale = User.current.language.blank? ? ::I18n.locale : User.current.language %>
<p><%= setting_select :date_format, Setting::DATE_FORMATS.collect {|f| [::I18n.l(Date.today, :locale => locale, :format => f), f]}, :blank => :label_language_based %></p>
<p><%= f.text_field :firstname, :required => true %></p>
<p><%= f.text_field :lastname, :required => true %></p>
<p><%= f.text_field :mail, :required => true %></p>
+ <% unless @user.force_default_language? %>
<p><%= f.select :language, lang_options_for_select %></p>
+ <% end %>
<% if Setting.openid? %>
<p><%= f.text_field :identity_url %></p>
<% end %>
setting_jsonp_enabled: Enable JSONP support
setting_default_projects_tracker_ids: Default trackers for new projects
setting_mail_handler_excluded_filenames: Exclude attachments by name
+ setting_force_default_language_for_anonymous: Force default language for anonymous users
+ setting_force_default_language_for_loggedin: Force default language for logged-in users
permission_add_project: Create project
permission_add_subprojects: Create subprojects
setting_jsonp_enabled: Activer le support JSONP
setting_default_projects_tracker_ids: Trackers par défaut pour les nouveaux projets
setting_mail_handler_excluded_filenames: Exclure les fichiers attachés par leur nom
+ setting_force_default_language_for_anonymous: Forcer la langue par défault pour les utilisateurs anonymes
+ setting_force_default_language_for_loggedin: Forcer la langue par défault pour les utilisateurs identifiés
permission_add_project: Créer un projet
permission_add_subprojects: Créer des sous-projets
default: ""
default_language:
default: en
+force_default_language_for_anonymous:
+ default: 0
+force_default_language_for_loggedin:
+ default: 0
host_name:
default: localhost:3000
protocol:
text-align: left;
float: none;
display: block;
- width: auto;
+ width: auto !important;
}
.tabular label.inline{
assert_no_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
end
+ def test_my_account_should_show_language_select
+ get :account
+ assert_response :success
+ assert_select 'select[name=?]', 'user[language]'
+ end
+
+ def test_my_account_should_not_show_language_select_with_force_default_language_for_loggedin
+ with_settings :force_default_language_for_loggedin => '1' do
+ get :account
+ assert_response :success
+ assert_select 'select[name=?]', 'user[language]', 0
+ end
+ end
+
def test_update_account
post :account,
:user => {
assert_equal :fr, @controller.current_language
end
+ def test_browser_language_should_be_ignored_with_force_default_language_for_anonymous
+ Setting.default_language = 'en'
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ with_settings :force_default_language_for_anonymous => '1' do
+ get :index
+ assert_equal :en, @controller.current_language
+ end
+ end
+
+ def test_user_language_should_be_used
+ Setting.default_language = 'fi'
+ user = User.find(2).update_attribute :language, 'it'
+ @request.session[:user_id] = 2
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ get :index
+ assert_equal :it, @controller.current_language
+ end
+
+ def test_user_language_should_be_ignored_if_force_default_language_for_loggedin
+ Setting.default_language = 'fi'
+ user = User.find(2).update_attribute :language, 'it'
+ @request.session[:user_id] = 2
+ @request.env['HTTP_ACCEPT_LANGUAGE'] = 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
+ with_settings :force_default_language_for_loggedin => '1' do
+ get :index
+ assert_equal :fi, @controller.current_language
+ end
+ end
+
def test_robots
get :robots
assert_response :success