Add a site setting to allow users to toggle I18n.locale

It is false by default.
This commit is contained in:
Jonathan Allard
2014-02-18 14:54:00 -05:00
parent c513725f26
commit 0592420e52
7 changed files with 29 additions and 9 deletions
@@ -11,6 +11,10 @@ Discourse.PreferencesController = Discourse.ObjectController.extend({
return Discourse.SiteSettings.allow_uploaded_avatars;
}.property(),
allowUserLocale: function() {
return Discourse.SiteSettings.allow_user_locale;
}.property(),
// By default we haven't saved anything
saved: false,
@@ -66,15 +66,17 @@
</div>
</div>
<div class="control-group">
<label class="control-label">{{i18n user.locale.title}}</label>
<div class="controls">
{{combobox valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}}
{{#if allowUserLocale}}
<div class="control-group">
<label class="control-label">{{i18n user.locale.title}}</label>
<div class="controls">
{{combobox valueAttribute="value" content=availableLocales value=locale none="user.locale.default"}}
</div>
<div class='instructions'>
{{i18n user.locale.instructions}}
</div>
</div>
<div class='instructions'>
{{i18n user.locale.instructions}}
</div>
</div>
{{/if}}
<div class="control-group">
<label class="control-label">{{i18n user.bio}}</label>
+1 -1
View File
@@ -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