diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 79d3d48aa61..16a7e719628 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -109,7 +109,7 @@ class ApplicationController < ActionController::Base
end
def set_locale
- I18n.locale = if current_user && current_user.locale.present?
+ I18n.locale = if SiteSetting.allow_user_locale && current_user && current_user.locale.present?
current_user.locale
else
SiteSetting.default_locale
diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml
index 74d7cc3c3fc..326d4aab9cc 100644
--- a/config/locales/server.en.yml
+++ b/config/locales/server.en.yml
@@ -549,6 +549,7 @@ en:
site_settings:
default_locale: "The default language of this Discourse instance (ISO 639-1 Code)"
+ allow_user_locale: "Allow users to choose their own language interface preference"
min_post_length: "Minimum post length in characters"
min_private_message_post_length: "Minimum post length in characters for private messages"
max_post_length: "Maximum post length in characters"
diff --git a/config/locales/server.fr.yml b/config/locales/server.fr.yml
index 71be63bd0ae..0826f145698 100644
--- a/config/locales/server.fr.yml
+++ b/config/locales/server.fr.yml
@@ -484,6 +484,7 @@ fr:
description: "HTML qui sera ajouté au pied de toutes les pages"
site_settings:
default_locale: "Le langage par défaut de cette instance de Discourse (code ISO 639-1)"
+ allow_user_locale: "Permettre aux utilisateurs de choisir leur propre préférence de langue pour l'interface"
min_post_length: "Longueur minimale des messages en nombre de caractères"
min_private_message_post_length: "Longueur minimale des messages privés en nombre de caractères"
max_post_length: "Longueur maximale des messages en nombres de caractères"
diff --git a/config/site_settings.yml b/config/site_settings.yml
index 5f1579fce50..5c3241c28d1 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -24,6 +24,9 @@ basic:
default_locale:
default: 'en'
enum: 'LocaleSiteSetting'
+ allow_user_locale:
+ client: true
+ default: false
ga_tracking_code:
client: true
default: ''
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 0cfc4ea80e5..0827176469b 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -55,6 +55,15 @@ describe TopicsController do
I18n.locale.should == :fr
end
+
+ it 'is sets the default locale when the setting not enabled' do
+ user = Fabricate(:user, locale: :fr)
+ log_in_user(user)
+
+ get :show, {topic_id: topic.id}
+
+ I18n.locale.should == :en
+ end
end
end