mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 07:37:55 +08:00
FIX: Don't store translated trust level names in anonymous cache (#13224)
Refactors `TrustLevel` and moves translations from server to client Additional changes: * "staff" and "admin" wasn't translatable in site settings * it replaces a concatenated string with a translation * uses translation for trust levels in users_by_trust_level report * adds a DB migration to rename keys of translation overrides affected by this commit
This commit is contained in:
@ -4,8 +4,6 @@ class InvalidTrustLevel < StandardError; end
|
||||
|
||||
class TrustLevel
|
||||
|
||||
attr_reader :id, :name
|
||||
|
||||
class << self
|
||||
|
||||
def [](level)
|
||||
@ -17,12 +15,6 @@ class TrustLevel
|
||||
@levels ||= Enum.new(:newuser, :basic, :member, :regular, :leader, start: 0)
|
||||
end
|
||||
|
||||
def all
|
||||
levels.map do |name_key, id|
|
||||
TrustLevel.new(name_key, id)
|
||||
end
|
||||
end
|
||||
|
||||
def valid?(level)
|
||||
valid_range === level
|
||||
end
|
||||
@ -35,15 +27,9 @@ class TrustLevel
|
||||
(current_level || 0) >= level
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def initialize(name_key, id)
|
||||
@name = I18n.t("trust_levels.#{name_key}.title")
|
||||
@id = id
|
||||
end
|
||||
|
||||
def serializable_hash
|
||||
{ id: @id, name: @name }
|
||||
def name(level)
|
||||
I18n.t("js.trust_levels.names.#{levels[level]}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user