FIX: 🈂️ Allow closing polls in multi-locale sites

This commit is contained in:
riking
2015-02-05 19:38:51 -08:00
parent 1ec46e3efd
commit 06f02ce9fc
7 changed files with 25 additions and 24 deletions

View File

@@ -147,8 +147,8 @@ class ApplicationController < ActionController::Base
end
def set_locale
I18n.locale = if SiteSetting.allow_user_locale && current_user && current_user.locale.present?
current_user.locale
I18n.locale = if current_user
current_user.effective_locale
else
SiteSetting.default_locale
end

View File

@@ -138,6 +138,14 @@ class User < ActiveRecord::Base
User.where(username_lower: lower).blank?
end
def effective_locale
if SiteSetting.allow_user_locale && self.locale.present?
self.locale
else
SiteSetting.default_locale
end
end
EMAIL = %r{([^@]+)@([^\.]+)}
def self.new_from_params(params)

View File

@@ -118,11 +118,7 @@ class PostAlerter
if collapsed
post = first_unread_post(user,post.topic) || post
count = unread_count(user, post.topic)
I18n.with_locale(if SiteSetting.allow_user_locale && user.locale.present?
user.locale
else
SiteSetting.default_locale
end) do
I18n.with_locale(user.effective_locale) do
opts[:display_username] = I18n.t('embed.replies', count: count) if count > 1
end
end